From b93dea04f486ed17420bd9c88572bf6211e03ce9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Krzysztof=20Kosi=C5=84ski?= Date: Sun, 31 Jan 2010 21:38:02 +0100 Subject: [PATCH] Fix crash when trying to import a corrupted PNG file. --- src/sp-image.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/sp-image.cpp b/src/sp-image.cpp index daf5e9e88..22b836703 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -328,6 +328,16 @@ static GdkPixbuf* pixbuf_new_from_file( const char *filename, time_t &modTime, g ); if ( pngPtr ) { + if ( setjmp(png_jmpbuf(pngPtr)) ) + { + // libpng calls longjmp to return here if an error occurs. + png_destroy_read_struct( &pngPtr, &infoPtr, NULL ); + fclose(fp); + gdk_pixbuf_loader_close(loader, NULL); + g_object_unref(loader); + return NULL; + } + infoPtr = png_create_info_struct( pngPtr ); //endPtr = png_create_info_struct( pngPtr ); -- 2.30.2