This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: fix two GCJ_PROPERTIES bugs
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 24 Jan 2006 11:04:27 -0700
- Subject: Patch: FYI: fix two GCJ_PROPERTIES bugs
- Reply-to: tromey at redhat dot com
I'm checking this in on the trunk and the 4.1 branch.
Archit found a couple of bugs with GCJ_PROPERTIES.
First, when next_property_value returns NULL, we would get a crash.
This can be reproduced with 'GCJ_PROPERTIES=a gij foo'.
Second, we overwrite the value of the GCJ_PROPERTIES environment
variable during startup; this means that settings here aren't properly
passed to subprocesses.
Patch appended.
Tom
Index: ChangeLog
from Archit Shah <ashah@redhat.com>
Tom Tromey <tromey@redhat.com>
* prims.cc (next_property_value): Never return NULL.
(process_gcj_properties): Copy 'props' before using it.
Index: prims.cc
===================================================================
--- prims.cc (revision 109935)
+++ prims.cc (working copy)
@@ -857,10 +857,6 @@
while (isspace (*s))
s++;
- // If we've reached the end, return NULL.
- if (*s == 0)
- return NULL;
-
// Determine the length of the property value.
while (s[l] != 0
&& ! isspace (s[l])
@@ -883,13 +879,18 @@
process_gcj_properties ()
{
char *props = getenv("GCJ_PROPERTIES");
+
+ if (NULL == props)
+ return;
+
+ // Later on we will write \0s into this string. It is simplest to
+ // just duplicate it here.
+ props = strdup (props);
+
char *p = props;
size_t length;
size_t property_count = 0;
- if (NULL == props)
- return;
-
// Whip through props quickly in order to count the number of
// property values.
while (p && (p = next_property_key (p, &length)))