diff src/dumper.c @ 4388:1a14c304cb8e

Don't use PATH_MAX_EXTERNAL, non-Win32. 2008-01-08 Aidan Kehoe <kehoea@parhasard.net> * text.h (MAX_XETCHAR_SIZE): Remove, eliminating a redefinition warning on Win32. * dumper.c (pdump_load): Don't use PATH_MAX_EXTERNAL, instead allocate enough for the path + DUMP_SLACK (space for .dmp and version information), already used on Win32 and #defined to be 100.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 09 Jan 2008 00:28:17 +0100
parents 1ce0622a56a3
children 19a72041c5ed
line wrap: on
line diff
--- a/src/dumper.c	Tue Jan 08 12:47:42 2008 -0700
+++ b/src/dumper.c	Wed Jan 09 00:28:17 2008 +0100
@@ -2630,6 +2630,8 @@
   return 0;
 }
 
+#define DUMP_SLACK 100 /* Enough to include dump ID, version name, .DMP */
+
 int
 pdump_load (const Wexttext *argv0)
 {
@@ -2637,7 +2639,6 @@
   Wexttext *exe_path = NULL;
   int bufsize = 4096;
   int cchpathsize;
-#define DUMP_SLACK 100 /* Enough to include dump ID, version name, .DMP */
 
   /* Copied from mswindows_get_module_file_name ().  Not clear if it's
      kosher to malloc() yet. */
@@ -2659,7 +2660,7 @@
       wext_strcpy (exe_path, wexe);
     }
 #else /* !WIN32_NATIVE */
-  Wexttext exe_path[PATH_MAX_EXTERNAL];
+  Wexttext *exe_path;
   Wexttext *w;
   const Wexttext *dir, *p;
 
@@ -2694,13 +2695,17 @@
     {
       /* invocation-name includes a directory component -- presumably it
 	 is relative to cwd, not $PATH. */
+      exe_path = alloca_array (Wexttext, 1 + wext_strlen (dir) + DUMP_SLACK);
       wext_strcpy (exe_path, dir);
     }
   else
     {
       const Wexttext *path = wext_getenv ("PATH"); /* not egetenv --
-						     not yet init. */
+                                                      not yet init. */
       const Wexttext *name = p;
+      exe_path = alloca_array (Wexttext,
+			       1 + DUMP_SLACK + max (wext_strlen (name),
+                                                     wext_strlen (path)));
       for (;;)
 	{
 	  p = path;