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,