From 858833a247255578ebf48665da147ea58c3302c7 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <randrianasulu@gmail.com>
Date: Sun, 12 Dec 2021 20:19:02 +0300
Subject: [PATCH 09/11] filegif.C crash fix

---
 cinelerra-5.1/cinelerra/filegif.C | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/cinelerra-5.1/cinelerra/filegif.C b/cinelerra-5.1/cinelerra/filegif.C
index bb26762b..baaa46af 100644
--- a/cinelerra-5.1/cinelerra/filegif.C
+++ b/cinelerra-5.1/cinelerra/filegif.C
@@ -335,6 +335,10 @@ int FileGIF::read_next_image(VFrame *output)
 	if( ret > 0 && output ) {
 		int screen_width = gif_file->SWidth;
 		int screen_height = gif_file->SHeight;
+		int output_w = output->get_w();
+		int output_h = output->get_h();
+		if (screen_width != output_w || screen_height != output_h)
+			return -1;
 		for( int i=0; i<screen_height; ++i ) {
 			GifRowType row = buffer[i];
 			unsigned char *out_ptr = output->get_rows()[i];
-- 
2.34.1

