From 385b5d3cda7099bebbdbae9f31bcb10834439c4f Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 27 Apr 2020 15:03:25 -0400 Subject: [PATCH] stbi__stdio_eof() should check ferror(), too. Otherwise with filesystem errors, you might end up with a short read but believe there's still more to read from the file, causing infinite loops. --- stb_image.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stb_image.h b/stb_image.h index 6f079ab..ebee9c3 100644 --- a/stb_image.h +++ b/stb_image.h @@ -799,7 +799,7 @@ static void stbi__stdio_skip(void *user, int n) static int stbi__stdio_eof(void *user) { - return feof((FILE*) user); + return feof((FILE*) user) || ferror((FILE *) user); } static stbi_io_callbacks stbi__stdio_callbacks =