avformat/mpegenc: Check for av_mallocz() failure
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 21 Dec 2016 22:41:49 +0000 (23:41 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 21 Dec 2016 22:41:49 +0000 (23:41 +0100)
Fixes CID1257787

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mpegenc.c

index 878fa63..c77c3df 100644 (file)
@@ -1146,6 +1146,8 @@ static int mpeg_mux_write_packet(AVFormatContext *ctx, AVPacket *pkt)
         stream->next_packet = &stream->premux_packet;
     *stream->next_packet     =
     pkt_desc                 = av_mallocz(sizeof(PacketDesc));
         stream->next_packet = &stream->premux_packet;
     *stream->next_packet     =
     pkt_desc                 = av_mallocz(sizeof(PacketDesc));
+    if (!pkt_desc)
+        return AVERROR(ENOMEM);
     pkt_desc->pts            = pts;
     pkt_desc->dts            = dts;
     pkt_desc->unwritten_size =
     pkt_desc->pts            = pts;
     pkt_desc->dts            = dts;
     pkt_desc->unwritten_size =