]> git.sesse.net Git - vlc/commitdiff
* modules/codec/png.c: More robust error checking, avoid calling abort() in
authorChristophe Massiot <massiot@videolan.org>
Thu, 6 Apr 2006 15:53:06 +0000 (15:53 +0000)
committerChristophe Massiot <massiot@videolan.org>
Thu, 6 Apr 2006 15:53:06 +0000 (15:53 +0000)
   case of an invalid file.

modules/codec/png.c

index 612d0e34a960bb57a105f21e99d694793061d7bc..0e7b108b5ef1397eaa35c30d441d16eb5960d909 100644 (file)
@@ -137,9 +137,32 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     p_sys->b_error = VLC_FALSE;
 
     p_png = png_create_read_struct( PNG_LIBPNG_VER_STRING, 0, 0, 0 );
+    if( p_png == NULL )
+    {
+        block_Release( p_block ); *pp_block = NULL;
+        return NULL;
+    }
+    
     p_info = png_create_info_struct( p_png );
+    if( p_info == NULL )
+    {
+        png_destroy_read_struct( &p_png, png_infopp_NULL, png_infopp_NULL );
+        block_Release( p_block ); *pp_block = NULL;
+        return NULL;
+    }
+
     p_end_info = png_create_info_struct( p_png );
+    if( p_end_info == NULL )
+    {
+        png_destroy_read_struct( &p_png, &p_info, png_infopp_NULL );
+        block_Release( p_block ); *pp_block = NULL;
+        return NULL;
+    }
  
+    /* libpng longjmp's there in case of error */
+    if( setjmp( png_jmpbuf( p_png ) ) )
+        goto error;
+
     png_set_read_fn( p_png, (void *)p_block, user_read );
     png_set_error_fn( p_png, (void *)p_dec, user_error, user_warning );