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/ftell.c')
-rw-r--r--newlib/libc/stdio/ftell.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/newlib/libc/stdio/ftell.c b/newlib/libc/stdio/ftell.c
index 6a8061816..8066acc3b 100644
--- a/newlib/libc/stdio/ftell.c
+++ b/newlib/libc/stdio/ftell.c
@@ -80,6 +80,8 @@ _DEFUN (ftell, (fp),
{
fpos_t pos;
+ _flockfile(fp);
+
/* Ensure stdio is set up. */
CHECK_INIT (fp);
@@ -87,6 +89,7 @@ _DEFUN (ftell, (fp),
if (fp->_seek == NULL)
{
fp->_data->_errno = ESPIPE;
+ _funlockfile(fp);
return -1L;
}
@@ -99,7 +102,10 @@ _DEFUN (ftell, (fp),
{
pos = (*fp->_seek) (fp->_cookie, (fpos_t) 0, SEEK_CUR);
if (pos == -1L)
- return pos;
+ {
+ _funlockfile(fp);
+ return pos;
+ }
}
if (fp->_flags & __SRD)
{
@@ -122,5 +128,6 @@ _DEFUN (ftell, (fp),
pos += fp->_p - fp->_bf._base;
}
+ _funlockfile(fp);
return pos;
}