Mercurial > mplayer.hg
changeset 33139:64f29d5dfea2
Prevent segmentation faults.
Check returned pointers. (Besides, add cosmetic newlines.)
author | ib |
---|---|
date | Tue, 05 Apr 2011 14:48:22 +0000 |
parents | 3335d117f6e6 |
children | d57654eb9f31 |
files | gui/util/bitmap.c |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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));