From: Owen Shepherd Date: Wed, 20 Feb 2013 01:01:40 +0000 (+0000) Subject: gets: lock file before performing read X-Git-Url: https://pd.if.org/git/?p=pdclib;a=commitdiff_plain;h=e836b9b3bd886a45b4493b22989ee9b322a02e9e gets: lock file before performing read --- diff --git a/functions/stdio/gets.c b/functions/stdio/gets.c index 83a261e..798df76 100644 --- a/functions/stdio/gets.c +++ b/functions/stdio/gets.c @@ -14,13 +14,16 @@ 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';