# HG changeset patch # User ib # Date 1302014902 0 # Node ID 64f29d5dfea2f55f4afa094c35accc8d4218af68 # Parent 3335d117f6e64cba9cdcea4313d931edceef8d15 Prevent segmentation faults. Check returned pointers. (Besides, add cosmetic newlines.) diff -r 3335d117f6e6 -r 64f29d5dfea2 gui/util/bitmap.c --- a/gui/util/bitmap.c Tue Apr 05 13:49:22 2011 +0000 +++ b/gui/util/bitmap.c Tue Apr 05 14:48:22 2011 +0000 @@ -65,13 +65,23 @@ 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));