[xiph-commits] r16146 - trunk/ffmpeg2theora/src

j at svn.xiph.org j at svn.xiph.org
Wed Jun 17 23:10:25 PDT 2009


Author: j
Date: 2009-06-17 23:10:25 -0700 (Wed, 17 Jun 2009)
New Revision: 16146

Modified:
   trunk/ffmpeg2theora/src/avinfo.c
Log:
dont return local variable

Modified: trunk/ffmpeg2theora/src/avinfo.c
===================================================================
--- trunk/ffmpeg2theora/src/avinfo.c	2009-06-18 05:45:17 UTC (rev 16145)
+++ trunk/ffmpeg2theora/src/avinfo.c	2009-06-18 06:10:25 UTC (rev 16146)
@@ -100,7 +100,7 @@
 
 char *replace_str(char *str, char *orig, char *rep) {
   char buffer[4096];
-  char *p, *p2, *rest;
+  char *p, *rest, *ret;
 
   if(!(p = strstr(str, orig)))
     return str;
@@ -109,7 +109,11 @@
   buffer[p-str] = '\0';
   rest = replace_str(p+strlen(orig), orig, rep);
   sprintf(buffer+(p-str), "%s%s", rep, rest);
-  return buffer;
+
+  ret = malloc(strlen(buffer)+1); // not zero terminated, so make it so
+  strncpy(ret, buffer, strlen(buffer));
+  ret[strlen(buffer)] = '\0';
+  return ret;
 }
 
 enum {
@@ -120,7 +124,7 @@
 } JSON_TYPES;
 
 void json_add_key_value(FILE *output, char *key, void *value, int type, int last) {
-    char *p, *pp;
+    char *p;
     switch(type) {
         case JSON_STRING:
             p = (char *)value;



More information about the commits mailing list