diff options
Diffstat (limited to 'libjava/classpath')
| -rw-r--r-- | libjava/classpath/ChangeLog | 6 | ||||
| -rw-r--r-- | libjava/classpath/native/jni/classpath/jcl.c | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/libjava/classpath/ChangeLog b/libjava/classpath/ChangeLog index 1a39f6b48d5..c3d8f6395b6 100644 --- a/libjava/classpath/ChangeLog +++ b/libjava/classpath/ChangeLog @@ -1,3 +1,9 @@ +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. + 2008-03-09 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> * doc/cp-hacking.texinfo: Fix spacing after periods. diff --git a/libjava/classpath/native/jni/classpath/jcl.c b/libjava/classpath/native/jni/classpath/jcl.c index cd3f5161d06..0180ab9f0f5 100644 --- a/libjava/classpath/native/jni/classpath/jcl.c +++ b/libjava/classpath/native/jni/classpath/jcl.c @@ -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 @@ JCL_malloc (JNIEnv * env, size_t size) 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; |

