]> pd.if.org Git - pdclib.old/commitdiff
gets: lock file before performing read
authorOwen Shepherd <owen.shepherd@e43.eu>
Wed, 20 Feb 2013 01:01:40 +0000 (01:01 +0000)
committerOwen Shepherd <owen.shepherd@e43.eu>
Wed, 20 Feb 2013 01:01:40 +0000 (01:01 +0000)
functions/stdio/gets.c

index 83a261efd6744001414b25dcf2f234afb32bccb9..798df766c08590d1d3953667714f3331a105becb 100644 (file)
 
 char * gets( char * s )
 {
+    _PDCLIB_flockfile( stdin );
     if ( _PDCLIB_prepread( stdin ) == EOF )
     {
+        _PDCLIB_funlockfile( stdin );
         return NULL;
     }
     char * dest = s;
     
     dest += _PDCLIB_getchars( dest, SIZE_MAX, '\n', stdin );
+    _PDCLIB_funlockfile( stdin );
 
     if(*(dest - 1) == '\n') {
         *(--dest) = '\0';