From f54eceace37cfe71701b1276cc5836245c73751b Mon Sep 17 00:00:00 2001 From: Keith McGuigan Date: Thu, 31 Jan 2008 09:41:34 -0500 Subject: [PATCH] 6631248: Memory problem when doing invalid type cast Changed memory allocation method for exception method Reviewed-by: ysr, never --- hotspot/src/share/vm/runtime/sharedRuntime.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp index e9a5685889d..5d507d165fd 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp @@ -1481,11 +1481,9 @@ char* SharedRuntime::generate_class_cast_message( const char* desc = " cannot be cast to "; size_t msglen = strlen(objName) + strlen(desc) + strlen(targetKlassName) + 1; - char* message = NEW_C_HEAP_ARRAY(char, msglen); + char* message = NEW_RESOURCE_ARRAY(char, msglen); if (NULL == message) { - // out of memory - can't use a detailed message. Since caller is - // using a resource mark to free memory, returning this should be - // safe (caller won't explicitly delete it). + // Shouldn't happen, but don't cause even more problems if it does message = const_cast(objName); } else { jio_snprintf(message, msglen, "%s%s%s", objName, desc, targetKlassName);