diff options
Diffstat (limited to 'meta/packages/gcc/gcc-4.3.1/debian/libjava-realloc-leak.dpatch')
| -rw-r--r-- | meta/packages/gcc/gcc-4.3.1/debian/libjava-realloc-leak.dpatch | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/meta/packages/gcc/gcc-4.3.1/debian/libjava-realloc-leak.dpatch b/meta/packages/gcc/gcc-4.3.1/debian/libjava-realloc-leak.dpatch new file mode 100644 index 0000000000..6bf7a7310f --- /dev/null +++ b/meta/packages/gcc/gcc-4.3.1/debian/libjava-realloc-leak.dpatch | |||
| @@ -0,0 +1,79 @@ | |||
| 1 | #! /bin/sh -e | ||
| 2 | |||
| 3 | # DP: Don't leak upon failed realloc (taken from the trunk). | ||
| 4 | |||
| 5 | dir= | ||
| 6 | if [ $# -eq 3 -a "$2" = '-d' ]; then | ||
| 7 | pdir="-d $3" | ||
| 8 | dir="$3/" | ||
| 9 | elif [ $# -ne 1 ]; then | ||
| 10 | echo >&2 "`basename $0`: script expects -patch|-unpatch as argument" | ||
| 11 | exit 1 | ||
| 12 | fi | ||
| 13 | case "$1" in | ||
| 14 | -patch) | ||
| 15 | patch $pdir -f --no-backup-if-mismatch -p0 < $0 | ||
| 16 | ;; | ||
| 17 | -unpatch) | ||
| 18 | patch $pdir -f --no-backup-if-mismatch -R -p0 < $0 | ||
| 19 | ;; | ||
| 20 | *) | ||
| 21 | echo >&2 "`basename $0`: script expects -patch|-unpatch as argument" | ||
| 22 | exit 1 | ||
| 23 | esac | ||
| 24 | exit 0 | ||
| 25 | |||
| 26 | libjava/ | ||
| 27 | |||
| 28 | 2008-03-10 Jim Meyering <meyering@redhat.com> | ||
| 29 | |||
| 30 | Don't leak upon failed realloc. | ||
| 31 | * gnu/classpath/natSystemProperties.cc | ||
| 32 | (SystemProperties::insertSystemProperties): | ||
| 33 | |||
| 34 | libjava/classpath/ | ||
| 35 | |||
| 36 | 2008-03-10 Jim Meyering <meyering@redhat.com> | ||
| 37 | |||
| 38 | Don't leak upon failed realloc. | ||
| 39 | * native/jni/classpath/jcl.c (JCL_realloc): Upon failed realloc, | ||
| 40 | free the original buffer before throwing the exception. | ||
| 41 | |||
| 42 | Index: libjava/classpath/native/jni/classpath/jcl.c | ||
| 43 | =================================================================== | ||
| 44 | --- libjava/classpath/native/jni/classpath/jcl.c (revision 133093) | ||
| 45 | +++ libjava/classpath/native/jni/classpath/jcl.c (revision 133094) | ||
| 46 | @@ -1,5 +1,5 @@ | ||
| 47 | /* jcl.c | ||
| 48 | - Copyright (C) 1998, 2005, 2006 Free Software Foundation, Inc. | ||
| 49 | + Copyright (C) 1998, 2005, 2006, 2008 Free Software Foundation, Inc. | ||
| 50 | |||
| 51 | This file is part of GNU Classpath. | ||
| 52 | |||
| 53 | @@ -152,9 +152,11 @@ | ||
| 54 | JNIEXPORT void *JNICALL | ||
| 55 | JCL_realloc (JNIEnv * env, void *ptr, size_t size) | ||
| 56 | { | ||
| 57 | + void *orig_ptr = ptr; | ||
| 58 | ptr = realloc (ptr, size); | ||
| 59 | if (ptr == 0) | ||
| 60 | { | ||
| 61 | + free (orig_ptr); | ||
| 62 | JCL_ThrowException (env, "java/lang/OutOfMemoryError", | ||
| 63 | "malloc() failed."); | ||
| 64 | return NULL; | ||
| 65 | Index: libjava/gnu/classpath/natSystemProperties.cc | ||
| 66 | =================================================================== | ||
| 67 | --- libjava/gnu/classpath/natSystemProperties.cc (revision 133093) | ||
| 68 | +++ libjava/gnu/classpath/natSystemProperties.cc (revision 133094) | ||
| 69 | @@ -270,7 +270,10 @@ | ||
| 70 | if (errno != ERANGE) | ||
| 71 | break; | ||
| 72 | buflen = 2 * buflen; | ||
| 73 | + char *orig_buf = buffer; | ||
| 74 | buffer = (char *) realloc (buffer, buflen); | ||
| 75 | + if (buffer == NULL) | ||
| 76 | + free (orig_buf); | ||
| 77 | } | ||
| 78 | if (buffer != NULL) | ||
| 79 | free (buffer); | ||
