Don't ignore the return value of fgets() and fread()

pull/3/head
Daniel Richard G 2013-08-26 16:48:41 -04:00
parent 1b00c8c3ab
commit 7715fd1bb8
2 changed files with 4 additions and 2 deletions

View File

@ -382,7 +382,8 @@ void SolveSpace::LoadUsingTable(char *key, char *val) {
for(;;) { for(;;) {
EntityMap em; EntityMap em;
char line2[1024]; char line2[1024];
fgets(line2, (int)sizeof(line2), fh); if (fgets(line2, (int)sizeof(line2), fh) == NULL)
break;
if(sscanf(line2, "%d %x %d", &(em.h.v), &(em.input.v), if(sscanf(line2, "%d %x %d", &(em.h.v), &(em.input.v),
&(em.copyNumber)) == 3) &(em.copyNumber)) == 3)
{ {

View File

@ -381,7 +381,8 @@ void TextWindow::ScreenBackgroundImage(int link, DWORD v) {
if(!f) goto err; if(!f) goto err;
BYTE header[8]; BYTE header[8];
fread(header, 1, 8, f); if (fread(header, 1, 8, f) != 8)
goto err;
if(png_sig_cmp(header, 0, 8)) goto err; if(png_sig_cmp(header, 0, 8)) goto err;
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,