matroskadec: check av_strdup() when setting defaults
authorAnton Khirnov <anton@khirnov.net>
Wed, 4 Sep 2013 06:55:17 +0000 (08:55 +0200)
committerAnton Khirnov <anton@khirnov.net>
Tue, 24 Sep 2013 15:11:50 +0000 (17:11 +0200)
libavformat/matroskadec.c

index dc32fd1..e6c9adf 100644 (file)
@@ -851,7 +851,13 @@ static int ebml_parse_nest(MatroskaDemuxContext *matroska, EbmlSyntax *syntax,
             break;
         case EBML_STR:
         case EBML_UTF8:
-            *(char    **)((char *)data+syntax[i].data_offset) = av_strdup(syntax[i].def.s);
+            // the default may be NULL
+            if (syntax[i].def.s) {
+                uint8_t **dst = (uint8_t**)((uint8_t*)data + syntax[i].data_offset);
+                *dst = av_strdup(syntax[i].def.s);
+                if (!*dst)
+                    return AVERROR(ENOMEM);
+            }
             break;
         }