diff mbox

[FFmpeg-devel] pngdec: check if previous frame exists instead of trusting sequence_number

Message ID a7816b0e-f35e-e72e-cf8a-23303b676817@googlemail.com
State Superseded
Headers show

Commit Message

Andreas Cadhalpun Nov. 25, 2016, 9:13 p.m. UTC
This fixes a segmentation fault caused by calling memcpy with NULL as
second argument in handle_p_frame_apng.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
---
 libavcodec/pngdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer Nov. 26, 2016, 12:53 a.m. UTC | #1
On Fri, Nov 25, 2016 at 10:13:06PM +0100, Andreas Cadhalpun wrote:
> This fixes a segmentation fault caused by calling memcpy with NULL as
> second argument in handle_p_frame_apng.
> 
> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
> ---
>  libavcodec/pngdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
> index 36275ae..a7b330b 100644
> --- a/libavcodec/pngdec.c
> +++ b/libavcodec/pngdec.c
> @@ -922,7 +922,7 @@ static int decode_fctl_chunk(AVCodecContext *avctx, PNGDecContext *s,
>          return AVERROR_INVALIDDATA;
>      }
>  
> -    if (sequence_number == 0 && dispose_op == APNG_DISPOSE_OP_PREVIOUS) {
> +    if (!s->previous_picture.f->data[0] && dispose_op == APNG_DISPOSE_OP_PREVIOUS) {
>          // No previous frame to revert to for the first frame
>          // Spec says to just treat it as a APNG_DISPOSE_OP_BACKGROUND
>          dispose_op = APNG_DISPOSE_OP_BACKGROUND;

wont this be different when seeking back to the
first frame ?
is that intended ?

[...]
diff mbox

Patch

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 36275ae..a7b330b 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -922,7 +922,7 @@  static int decode_fctl_chunk(AVCodecContext *avctx, PNGDecContext *s,
         return AVERROR_INVALIDDATA;
     }
 
-    if (sequence_number == 0 && dispose_op == APNG_DISPOSE_OP_PREVIOUS) {
+    if (!s->previous_picture.f->data[0] && dispose_op == APNG_DISPOSE_OP_PREVIOUS) {
         // No previous frame to revert to for the first frame
         // Spec says to just treat it as a APNG_DISPOSE_OP_BACKGROUND
         dispose_op = APNG_DISPOSE_OP_BACKGROUND;