From bcde12940007e836f7b831f1cdfda8dc2bda0c58 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Fri, 24 Apr 2009 22:52:52 +0000 Subject: 2009-04-24 Jeff johnston * 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. --- newlib/libc/stdio/gets.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'newlib/libc/stdio/gets.c') diff --git a/newlib/libc/stdio/gets.c b/newlib/libc/stdio/gets.c index 17d144316..daa42e954 100644 --- a/newlib/libc/stdio/gets.c +++ b/newlib/libc/stdio/gets.c @@ -79,12 +79,14 @@ _DEFUN(_gets_r, (ptr, buf), register int c; register char *s = buf; + __sfp_lock_acquire (); _flockfile (stdin); while ((c = __sgetc_r (ptr, stdin)) != '\n') if (c == EOF) if (s == buf) { _funlockfile (stdin); + __sfp_lock_release (); return NULL; } else @@ -93,6 +95,7 @@ _DEFUN(_gets_r, (ptr, buf), *s++ = c; *s = 0; _funlockfile (stdin); + __sfp_lock_release (); return buf; } -- cgit v1.2.3