[MPlayer-dev-eng] [PATCH] fix for unconditional use of PATH_MAX

Robert Millan zeratul2 at wanadoo.es
Mon Apr 28 19:20:03 CEST 2003


hi!

code in mplayer.c assumes PATH_MAX is declared, but this is
wrong since PATH_MAX is not enforced by POSIX, and system
implementation can choose not to have any limit in the length
of a path. this breaks build of mplayer on systems that
don't have PATH_MAX, like GNU (also known as GNU/Hurd).

please apply the attached patch to use dynamical allocation when
PATH_MAX is not defined.

-- 
Robert Millan

make: *** No rule to make target `war'.  Stop.

Another world is possible - Just say no to genocide
-------------- next part --------------
Only in mplayer-0.90/Gui: config.mak
Only in mplayer-0.90/TOOLS: cpuinfo
Only in mplayer-0.90/: config.h
Only in mplayer-0.90/: config.mak
Only in mplayer-0.90/: help_mp.h
Only in mplayer-0.90/libao2: config.mak
Only in mplayer-0.90/libvo: config.mak
diff -ur mplayer-0.90.old/mplayer.c mplayer-0.90/mplayer.c
--- mplayer-0.90.old/mplayer.c	2003-03-10 15:02:18.000000000 +0100
+++ mplayer-0.90/mplayer.c	2003-04-27 17:39:13.000000000 +0200
@@ -762,19 +762,34 @@
       use_gui=0;
     }
     if (use_gui && playtree_iter){
+#ifdef PATH_MAX
       char cwd[PATH_MAX+2];
+#else
+      char *cwd;
+#endif
       // Remove Playtree and Playtree-Iter from memory as its not used by gui
       play_tree_iter_free(playtree_iter);
       playtree_iter=NULL;
       
+#ifdef PATH_MAX
       if (getcwd(cwd, PATH_MAX) != (char *)NULL)
+#else
+      cwd = getcwd (NULL, 0);
+      if (cwd != (char *)NULL)
+#endif
       {
+#ifndef PATH_MAX
+          realloc (cwd, strlen (cwd) + 1);
+#endif
 	  strcat(cwd, "/");
           // Prefix relative paths with current working directory
           play_tree_add_bpf(playtree, cwd);
       }      
       // Import initital playtree into gui
       import_initial_playtree_into_gui(playtree, mconfig, enqueue);
+#ifndef PATH_MAX
+      free (cwd);
+#endif
     }
 #endif
 
Only in mplayer-0.90/: version.h


More information about the MPlayer-dev-eng mailing list