From c7e3850b9ab3cd656a548eec6b70ef4f5f68a101 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Tue, 11 Dec 2018 12:45:23 +0100 Subject: [PATCH] skip sub-blocks (except the 1st) in GFX2MODE GIF extension That's to be future proof and be able to add more data to this extension in the future ! --- src/fileformats.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/fileformats.c b/src/fileformats.c index 21061852..932de44c 100644 --- a/src/fileformats.c +++ b/src/fileformats.c @@ -4293,8 +4293,16 @@ void Load_GIF(T_IO_Context * context) label[size_to_read] = '\0'; image_mode = Constraint_mode_from_label(label); GFX2_Log(GFX2_DEBUG, " mode = %s (%d)\n", label, image_mode); - Read_byte(GIF_file,&size_to_read); free(label); + Read_byte(GIF_file,&size_to_read); + // be future proof, skip following sub-blocks : + while (size_to_read!=0 && !File_error) + { + if (fseek(GIF_file,size_to_read,SEEK_CUR) < 0) + File_error = 1; + if (!Read_byte(GIF_file,&size_to_read)) + File_error = 1; + } } } else @@ -4303,8 +4311,10 @@ void Load_GIF(T_IO_Context * context) Read_byte(GIF_file,&size_to_read); while (size_to_read!=0 && !File_error) { - fseek(GIF_file,size_to_read,SEEK_CUR); - Read_byte(GIF_file,&size_to_read); + if (fseek(GIF_file,size_to_read,SEEK_CUR) < 0) + File_error = 1; + if (!Read_byte(GIF_file,&size_to_read)) + File_error = 1; } } }