From: Krzysztof KosiƄski Date: Sun, 31 Jan 2010 20:38:02 +0000 (+0100) Subject: Fix crash when trying to import a corrupted PNG file. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b93dea04f486ed17420bd9c88572bf6211e03ce9;p=inkscape.git Fix crash when trying to import a corrupted PNG file. --- 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 );