mpegenc: prevent a NULL pointer dereference
[ffmpeg.git] / libavformat / mpegenc.c
index fed03ed..9640893 100644 (file)
@@ -1057,7 +1057,7 @@ retry:
         es_size              -= stream->premux_packet->unwritten_size;
         stream->premux_packet = stream->premux_packet->next;
     }
-    if (es_size)
+    if (stream->premux_packet && es_size)
         stream->premux_packet->unwritten_size -= es_size;
 
     if (remove_decoded_packets(ctx, s->last_scr) < 0)