Don't leak upon failed realloc.

libjava
2008-03-10  Jim Meyering  <meyering@redhat.com>
        Don't leak upon failed realloc.
        * gnu/classpath/natSystemProperties.cc
        (SystemProperties::insertSystemProperties):
libjava/classpath
2008-03-10  Jim Meyering  <meyering@redhat.com>
        Don't leak upon failed realloc.
        * native/jni/classpath/jcl.c (JCL_realloc): Upon failed realloc,
        free the original buffer before throwing the exception.

From-SVN: r133094
This commit is contained in:
Jim Meyering
2008-03-10 22:08:34 +00:00
committed by Tom Tromey
parent dd6d523630
commit ea1b8c8764
4 changed files with 18 additions and 1 deletions
@@ -270,7 +270,10 @@ gnu::classpath::SystemProperties::insertSystemProperties (::java::util::Properti
if (errno != ERANGE)
break;
buflen = 2 * buflen;
char *orig_buf = buffer;
buffer = (char *) realloc (buffer, buflen);
if (buffer == NULL)
free (orig_buf);
}
if (buffer != NULL)
free (buffer);