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]
Other format: [Raw text]

Patch: FYI: fix two GCJ_PROPERTIES bugs


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)))


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