Parrot_readbc can segfault when loading an absolute path to a file (in my
case, only under GDB).  the problem lies in Parrot_locate_runtime_file,
and is similar to the one in ticket #32087.

the attached patch adds a check in Parrot_locate_runtime_file so it
returns absolute paths as is.  it handles win32 paths (and drive letters)
as well.  hopefully i chose the most logical place for this -- i didn't
think it belonged in Parrot_readbc itself.

-jeff
diff -a -u -r1.14 library.c
--- src/library.c       16 Dec 2004 10:37:16 -0000      1.14
+++ src/library.c       4 Feb 2005 17:10:15 -0000
@@ -199,6 +199,19 @@
     if (!ext) {
         internal_exception(UNIMPLEMENTED, "no extension: file '%s'", 
file_name);
     }
+
+    /* use absolute paths as is */
+#ifdef WIN32
+    if (file_name[0] == '\\' || (isalpha(file_name[0]) && strncmp(file_name+1, 
":\\", 2) == 0)) {
+#else
+    if (file_name[0] == '/') {
+#endif
+        length = strlen(file_name) + 1;
+        full_name = mem_sys_allocate(length);
+        strcpy(full_name, file_name);
+        return full_name;
+    }
+
     length = 0;
     for (ptr = paths; *ptr; ++ptr) {
         int len = strlen(*ptr);

Reply via email to