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.old;a=commitdiff_plain;h=a31f895e9a7ac1aec1a7d188a52f04f0544879e2 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';