[xiph-commits] r12938 - trunk/theora/examples

giles at svn.xiph.org giles at svn.xiph.org
Wed May 9 19:48:29 PDT 2007


Author: giles
Date: 2007-05-09 19:48:29 -0700 (Wed, 09 May 2007)
New Revision: 12938

Modified:
   trunk/theora/examples/png2theora.c
Log:
basename() and dirname() can mangle their argument, and must be
passed scratch strings. Without this the filename filter is
not parsed properly on my Ubuntu Linux 7.04 system.


Modified: trunk/theora/examples/png2theora.c
===================================================================
--- trunk/theora/examples/png2theora.c	2007-05-09 22:55:01 UTC (rev 12937)
+++ trunk/theora/examples/png2theora.c	2007-05-10 02:48:29 UTC (rev 12938)
@@ -403,6 +403,7 @@
   int i, n;
   char *input_mask;
   char *input_directory;
+  char *scratch;
   struct dirent **png_files;
   
   while(1) {
@@ -437,20 +438,15 @@
      case 's':
        video_aspect_numerator=rint(atof(optarg));
        break;
-
      case 'S':
        video_aspect_denominator=rint(atof(optarg));
        break;
-
      case 'f':
        video_fps_numerator=rint(atof(optarg));
        break;
-
      case 'F':
-       video_fps_denominator=rint(atof(optarg));
-       break;
-    
-      default:
+       video_fps_denominator=rint(atof(optarg));   
+     default:
         usage();
         break;
       }
@@ -461,9 +457,14 @@
   }
 
   input_mask = argv[optind];
-  input_directory = dirname(input_mask);
-  input_filter = basename(input_mask);
-  
+  /* dirname and basename must operate on scratch strings */
+  scratch = strdup(input_mask);
+  input_directory = strdup(dirname(scratch));
+  free(scratch);
+  scratch = strdup(input_mask);
+  input_filter = strdup(basename(scratch));
+  free(scratch);
+
 #ifdef DEBUG
   fprintf(stderr, "scanning %s with filter '%s'\n",
 	input_directory, input_filter);
@@ -520,6 +521,8 @@
 
     if(theora_write_frame(w, h, yuv)) {
       theora_close();
+      free(input_directory);
+      free(input_filter);
       exit(1);
     }
 



More information about the commits mailing list