summaryrefslogtreecommitdiffstats
path: root/newlib/libc/stdio/freopen.c
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdio/freopen.c')
-rw-r--r--newlib/libc/stdio/freopen.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c
index 63f583375..ea61f0463 100644
--- a/newlib/libc/stdio/freopen.c
+++ b/newlib/libc/stdio/freopen.c
@@ -76,12 +76,15 @@ _DEFUN (freopen, (file, mode, fp),
int flags, oflags, e;
struct _reent *ptr;
+ _flockfile(fp);
+
CHECK_INIT (fp);
ptr = fp->_data;
if ((flags = __sflags (ptr, mode, &oflags)) == 0)
{
(void) fclose (fp);
+ _funlockfile(fp);
return NULL;
}
@@ -137,6 +140,7 @@ _DEFUN (freopen, (file, mode, fp),
{ /* did not get it after all */
fp->_flags = 0; /* set it free */
ptr->_errno = e; /* restore in case _close clobbered */
+ _funlockfile(fp);
return NULL;
}
@@ -153,5 +157,6 @@ _DEFUN (freopen, (file, mode, fp),
fp->_flags |= __SCLE;
#endif
+ _funlockfile(fp);
return fp;
}