From 7715fd1bb8129a30fe1a6f48f22e7e9debac10f7 Mon Sep 17 00:00:00 2001 From: Daniel Richard G Date: Mon, 26 Aug 2013 16:48:41 -0400 Subject: [PATCH] Don't ignore the return value of fgets() and fread() --- file.cpp | 3 ++- style.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/file.cpp b/file.cpp index 7ee35e2..1e6ace5 100644 --- a/file.cpp +++ b/file.cpp @@ -382,7 +382,8 @@ void SolveSpace::LoadUsingTable(char *key, char *val) { for(;;) { EntityMap em; 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), &(em.copyNumber)) == 3) { diff --git a/style.cpp b/style.cpp index 65ac5bf..047c0f8 100644 --- a/style.cpp +++ b/style.cpp @@ -381,7 +381,8 @@ void TextWindow::ScreenBackgroundImage(int link, DWORD v) { if(!f) goto err; 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; png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,