From 09d5929f3721613fbb9ac9e74265c89c70df2ce0 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michaelni@gmx.at>
Date: Mon, 1 Jul 2013 10:01:30 +0200
Subject: [PATCH] jpeg2000: Do not crash on NULL node in tag_tree_decode

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
---
 libavcodec/jpeg2000dec.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index ac44a29ff16..172314f40a7 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -119,6 +119,9 @@ static int tag_tree_decode(Jpeg2000DecoderContext *s, Jpeg2000TgtNode *node,
     Jpeg2000TgtNode *stack[30];
     int sp = -1, curval = 0;
 
+    if (!node)
+        return AVERROR_INVALIDDATA;
+
     while (node && !node->vis) {
         stack[++sp] = node;
         node        = node->parent;
-- 
GitLab