flvdec: Do not call parse_keyframes_index with a NULL stream

Message ID 1319232821-44822-1-git-send-email-martin@martin.st
State Committed
Commit f4b51d061f0f34e36be876b562b8abe47f4b9c1c
Headers show

Commit Message

Martin Storsjö Oct. 21, 2011, 9:33 p.m.
From: Reimar Döffinger <Reimar.Doeffinger@gmx.de>

---
 libavformat/flvdec.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

Comments

Luca Barbato Oct. 21, 2011, 9:40 p.m. | #1
On 10/21/11 2:33 PM, Martin Storsjö wrote:
> From: Reimar Döffinger<Reimar.Doeffinger@gmx.de>
>
> ---
>   libavformat/flvdec.c |    5 +++--
>   1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index 395c8f8..1459850 100644
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -239,8 +239,9 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
>           case AMF_DATA_TYPE_OBJECT: {
>               unsigned int keylen;
>
> -            if (key&&  !strcmp(KEYFRAMES_TAG, key)&&  depth == 1)
> -                if (parse_keyframes_index(s, ioc, vstream, max_pos)<  0)
> +            if ((vstream || astream)&&  key&&  !strcmp(KEYFRAMES_TAG, key)&&  depth == 1)
> +                if (parse_keyframes_index(s, ioc, vstream ? vstream : astream,
> +                                          max_pos)<  0)
>                       return -1;
>
>               while(avio_tell(ioc)<  max_pos - 2&&  (keylen = avio_rb16(ioc))) {

Seems ok.

Patch

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 395c8f8..1459850 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -239,8 +239,9 @@  static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
         case AMF_DATA_TYPE_OBJECT: {
             unsigned int keylen;
 
-            if (key && !strcmp(KEYFRAMES_TAG, key) && depth == 1)
-                if (parse_keyframes_index(s, ioc, vstream, max_pos) < 0)
+            if ((vstream || astream) && key && !strcmp(KEYFRAMES_TAG, key) && depth == 1)
+                if (parse_keyframes_index(s, ioc, vstream ? vstream : astream,
+                                          max_pos) < 0)
                     return -1;
 
             while(avio_tell(ioc) < max_pos - 2 && (keylen = avio_rb16(ioc))) {