I'm checking this in.

This is a realloc usage fix from Jim Meyering.

Tom

ChangeLog:
2008-03-10  Jim Meyering  <[EMAIL PROTECTED]>

        Don't leak upon failed realloc.
        * native/jni/classpath/jcl.c (JCL_realloc): Upon failed realloc,
        free the original buffer before throwing the exception.

Index: native/jni/classpath/jcl.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/classpath/jcl.c,v
retrieving revision 1.27
diff -u -r1.27 jcl.c
--- native/jni/classpath/jcl.c  17 Oct 2006 14:14:16 -0000      1.27
+++ native/jni/classpath/jcl.c  10 Mar 2008 19:00:27 -0000
@@ -1,5 +1,5 @@
 /* jcl.c
-   Copyright (C) 1998, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2005, 2006, 2008 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -152,9 +152,11 @@
 JNIEXPORT void *JNICALL
 JCL_realloc (JNIEnv * env, void *ptr, size_t size)
 {
+  void *orig_ptr = ptr;
   ptr = realloc (ptr, size);
   if (ptr == 0)
     {
+      free (orig_ptr);
       JCL_ThrowException (env, "java/lang/OutOfMemoryError",
                          "malloc() failed.");
       return NULL;

Reply via email to