diff wc3movie.c @ 5446:4211f91f69b1 libavformat

Use AV_METADATA_DONT_STRDUP* / use av_malloced metadata instead of strduped arrays of fixed length. Code from ffmbc with changes to adapt to our metadata API.
author michael
date Sun, 13 Dec 2009 20:27:29 +0000
parents 1273a2b9c32a
children 536e5527c1e0
line wrap: on
line diff
--- a/wc3movie.c	Sun Dec 13 20:22:27 2009 +0000
+++ b/wc3movie.c	Sun Dec 13 20:27:29 2009 +0000
@@ -140,10 +140,9 @@
     unsigned int fourcc_tag;
     unsigned int size;
     AVStream *st;
-    char buffer[513];
     int ret = 0;
     int current_palette = 0;
-    int bytes_to_read;
+    char *buffer;
     int i;
     unsigned char rotate;
 
@@ -185,14 +184,14 @@
 
         case BNAM_TAG:
             /* load up the name */
-            if ((unsigned)size < 512)
-                bytes_to_read = size;
-            else
-                bytes_to_read = 512;
-            if ((ret = get_buffer(pb, buffer, bytes_to_read)) != bytes_to_read)
+            buffer = av_malloc(size+1);
+            if (!buffer)
+                return AVERROR_NOMEM;
+            if ((ret = get_buffer(pb, buffer, size)) != size)
                 return AVERROR(EIO);
-            buffer[bytes_to_read] = 0;
-            av_metadata_set(&s->metadata, "title", buffer);
+            buffer[size] = 0;
+            av_metadata_set2(&s->metadata, "title", buffer,
+                                   AV_METADATA_DONT_STRDUP_VAL);
             break;
 
         case SIZE_TAG: