This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

name-finder fix


dladdr() seems to have started sometimes returning a null value for 
dli_fname in cases where the looked up address is in the main exe. We 
need to check for this to avoid a crash, this patch fixes.

regards

Bryce


2001-08-26  Bryce McKinlay  <bryce@waitaki.otago.ac.nz>

	* name-finder.cc (lookup): Ignore a null dli_fname from dladdr.

Index: name-finder.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/name-finder.cc,v
retrieving revision 1.6
diff -u -r1.6 name-finder.cc
--- name-finder.cc	2000/11/23 05:45:47	1.6
+++ name-finder.cc	2001/08/26 10:02:28
@@ -145,11 +145,13 @@
     
     if (dladdr (p, &dl_info))
       {
-	strncpy (file_name, dl_info.dli_fname, sizeof file_name);
+        if (dl_info.dli_fname)
+	  strncpy (file_name, dl_info.dli_fname, sizeof file_name);
 	strncpy (method_name, dl_info.dli_sname, sizeof method_name);
        
        /* Don't trust dladdr() if the address is from the main program. */
-       if (_Jv_argv == NULL || strcmp (file_name, _Jv_argv[0]) != 0)
+       if (dl_info.dli_fname != NULL
+	   && (_Jv_argv == NULL || strcmp (file_name, _Jv_argv[0]) != 0))
          return true;
       }
   }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]