# HG changeset patch # User andrew # Date 1344425822 -3600 # Node ID d87e86aaf2b3d4f892388f0ec009cf6396528c5e # Parent b0d6552ba3011f32446e048ee335d50c24ddfef0 7189533: GetJavaProperties should free temporary file if subsequent allocations fails Summary: Add missing calls to free Reviewed-by: alanb, dholmes, sherman diff -r b0d6552ba301 -r d87e86aaf2b3 src/solaris/native/java/lang/java_props_md.c --- a/src/solaris/native/java/lang/java_props_md.c Tue Aug 07 20:23:41 2012 -0700 +++ b/src/solaris/native/java/lang/java_props_md.c Wed Aug 08 12:37:02 2012 +0100 @@ -140,7 +140,7 @@ char *temp = NULL; char *language = NULL, *country = NULL, *variant = NULL, *encoding = NULL; - char *p, *encoding_variant; + char *p, *encoding_variant, *old_temp, *old_ev; char *lc; /* Query the locale set for the category */ @@ -219,6 +219,7 @@ encoding_variant = malloc(strlen(temp)+1); if (encoding_variant == NULL) { + free(temp); JNU_ThrowOutOfMemoryError(env, NULL); return 0; } @@ -234,14 +235,20 @@ } if (mapLookup(locale_aliases, temp, &p)) { + old_temp = temp; temp = realloc(temp, strlen(p)+1); if (temp == NULL) { + free(old_temp); + free(encoding_variant); JNU_ThrowOutOfMemoryError(env, NULL); return 0; } strcpy(temp, p); + old_ev = encoding_variant; encoding_variant = realloc(encoding_variant, strlen(temp)+1); if (encoding_variant == NULL) { + free(old_ev); + free(temp); JNU_ThrowOutOfMemoryError(env, NULL); return 0; }