This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
name-finder fix
- To: java-patches at gcc dot gnu dot org
- Subject: name-finder fix
- From: Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>
- Date: Sun, 26 Aug 2001 22:12:35 +1200
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;
}
}