From 38fd6679a33ecd336bc21027821e4e0b9fb0363a Mon Sep 17 00:00:00 2001 From: Archit Shah Date: Tue, 24 Jan 2006 18:10:39 +0000 Subject: prims.cc (next_property_value): Never return NULL. * prims.cc (next_property_value): Never return NULL. (process_gcj_properties): Copy 'props' before using it. Co-Authored-By: Tom Tromey From-SVN: r110177 --- libjava/ChangeLog | 6 ++++++ libjava/prims.cc | 15 ++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'libjava') diff --git a/libjava/ChangeLog b/libjava/ChangeLog index d13425b..a2357c3 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,9 @@ +2006-01-24 Archit Shah + Tom Tromey + + * prims.cc (next_property_value): Never return NULL. + (process_gcj_properties): Copy 'props' before using it. + 2006-01-23 Keith Seitz * java/lang/Class.h (_Jv_FindInterpreterMethod): Add new declaration. diff --git a/libjava/prims.cc b/libjava/prims.cc index 09bca0b..a968a9b 100644 --- a/libjava/prims.cc +++ b/libjava/prims.cc @@ -857,10 +857,6 @@ next_property_value (char *s, size_t *length) 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 @@ static void process_gcj_properties () { char *props = getenv("GCJ_PROPERTIES"); - char *p = props; - size_t length; - size_t property_count = 0; 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; + // Whip through props quickly in order to count the number of // property values. while (p && (p = next_property_key (p, &length))) -- cgit v1.1