diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index fed03ed31f..9640893414 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -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)