[MPlayer-cvslog] r33226 - trunk/gui/util/bitmap.c

ib subversion at mplayerhq.hu
Tue Apr 5 16:48:23 CEST 2011


Author: ib
Date: Tue Apr  5 16:48:22 2011
New Revision: 33226

Log:
Prevent segmentation faults.

Check returned pointers. (Besides, add cosmetic newlines.)

Modified:
   trunk/gui/util/bitmap.c

Modified: trunk/gui/util/bitmap.c
==============================================================================
--- trunk/gui/util/bitmap.c	Tue Apr  5 15:49:22 2011	(r33225)
+++ trunk/gui/util/bitmap.c	Tue Apr  5 16:48:22 2011	(r33226)
@@ -65,13 +65,23 @@ static int pngRead(unsigned char *fname,
 
     avctx = avcodec_alloc_context();
     frame = avcodec_alloc_frame();
+
+    if (!(avctx && frame)) {
+        av_free(frame);
+        av_free(avctx);
+        av_free(data);
+        return 5;
+    }
+
     avcodec_register_all();
     avcodec_open(avctx, avcodec_find_decoder(CODEC_ID_PNG));
+
     av_init_packet(&pkt);
     pkt.data = data;
     pkt.size = len;
     // HACK: make PNGs decode normally instead of as CorePNG delta frames
     pkt.flags = AV_PKT_FLAG_KEY;
+
     avcodec_decode_video2(avctx, frame, &decode_ok, &pkt);
 
     memset(bf, 0, sizeof(*bf));


More information about the MPlayer-cvslog mailing list