aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/stdio/fgetc.c
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2009-04-24 22:52:52 +0000
committerJeff Johnston <jjohnstn@redhat.com>2009-04-24 22:52:52 +0000
commitbcde12940007e836f7b831f1cdfda8dc2bda0c58 (patch)
treed9894d46eb51edf603939d8506bf0b5f97b9fa87 /newlib/libc/stdio/fgetc.c
parent35f31b6a983710aa9a2bd7e308d1567f326f3f5f (diff)
downloadnewlib-bcde12940007e836f7b831f1cdfda8dc2bda0c58.zip
newlib-bcde12940007e836f7b831f1cdfda8dc2bda0c58.tar.gz
newlib-bcde12940007e836f7b831f1cdfda8dc2bda0c58.tar.bz2
2009-04-24 Jeff johnston <jjohnstn@redhat.com>
* libc/stdio/fgetc.c: Make sure sfp lock is acquired before the file lock and released before the file lock to avoid a deadlock scenario. * libc/stdio/fgets.c: Ditto. * libc/stdio/fgetwc.c: Ditto. * libc/stdio/fgetws.c: Ditto. * libc/stdio/fread.c: Ditto. * libc/stdio/fseek.c: Ditto. * libc/stdio/getc.c: Ditto. * libc/stdio/getdelim.c: Ditto. * libc/stdio/gets.c: Ditto.
Diffstat (limited to 'newlib/libc/stdio/fgetc.c')
-rw-r--r--newlib/libc/stdio/fgetc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/newlib/libc/stdio/fgetc.c b/newlib/libc/stdio/fgetc.c
index e275cfe..9837a2e 100644
--- a/newlib/libc/stdio/fgetc.c
+++ b/newlib/libc/stdio/fgetc.c
@@ -93,9 +93,11 @@ _DEFUN(fgetc, (fp),
#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
int result;
CHECK_INIT(_REENT, fp);
+ __sfp_lock_acquire ();
_flockfile (fp);
result = __sgetc_r (_REENT, fp);
_funlockfile (fp);
+ __sfp_lock_release ();
return result;
#else
return _fgetc_r (_REENT, fp);