summaryrefslogtreecommitdiff
path: root/native
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2008-03-10 19:01:40 +0000
committerTom Tromey <tromey@redhat.com>2008-03-10 19:01:40 +0000
commit90246c32eaf76698be42bd431f5101f75163e157 (patch)
treef98ca9eb0de056fb2d0ec39de492d9121847322a /native
parentf6eb5c67210667b5942218ef91cfa670f2d09749 (diff)
downloadclasspath-90246c32eaf76698be42bd431f5101f75163e157.tar.gz
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.
Diffstat (limited to 'native')
-rw-r--r--native/jni/classpath/jcl.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/native/jni/classpath/jcl.c b/native/jni/classpath/jcl.c
index cd3f5161d..0180ab9f0 100644
--- a/native/jni/classpath/jcl.c
+++ b/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;