diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 7268c3b5cb..7d8697847d 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -4199,8 +4199,13 @@ again: hx->intra_gb_ptr = hx->inter_gb_ptr = NULL; - if ((err = decode_slice_header(hx, h)) < 0) + if ((err = decode_slice_header(hx, h)) < 0) { + /* make sure data_partitioning is cleared if it was set + * before, so we don't try decoding a slice without a valid + * slice header later */ + h->s.data_partitioning = 0; break; + } hx->s.data_partitioning = 1; break;