Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdio/fread.c')
-rw-r--r--newlib/libc/stdio/fread.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/newlib/libc/stdio/fread.c b/newlib/libc/stdio/fread.c
index 38f791b6d..faca53735 100644
--- a/newlib/libc/stdio/fread.c
+++ b/newlib/libc/stdio/fread.c
@@ -122,6 +122,8 @@ _DEFUN (fread, (buf, size, count, fp),
if ((resid = count * size) == 0)
return 0;
+
+ _flockfile(fp);
if (fp->_r < 0)
fp->_r = 0;
total = resid;
@@ -139,8 +141,12 @@ _DEFUN (fread, (buf, size, count, fp),
/* no more input: return partial result */
#ifdef __SCLE
if (fp->_flags & __SCLE)
- return crlf(fp, buf, total-resid, 1) / size;
+ {
+ _funlockfile(fp);
+ return crlf(fp, buf, total-resid, 1) / size;
+ }
#endif
+ _funlockfile(fp);
return (total - resid) / size;
}
}
@@ -149,7 +155,11 @@ _DEFUN (fread, (buf, size, count, fp),
fp->_p += resid;
#ifdef __SCLE
if (fp->_flags & __SCLE)
- return crlf(fp, buf, total, 0) / size;
+ {
+ _funlockfile(fp);
+ return crlf(fp, buf, total, 0) / size;
+ }
#endif
+ _funlockfile(fp);
return count;
}