# HG changeset patch # User kamg # Date 1201790494 18000 # Node ID 9785f6d2dd971f61475ab62e2b5cfe5529168f61 # Parent 92489cdc94d1ad7b1fa668b83e4bfa118247b06b 6631248: Memory problem when doing invalid type cast Summary: Changed memory allocation method for exception method Reviewed-by: ysr, never diff -r 92489cdc94d1 -r 9785f6d2dd97 src/share/vm/runtime/sharedRuntime.cpp --- a/src/share/vm/runtime/sharedRuntime.cpp Tue Dec 04 16:28:18 2007 -0800 +++ b/src/share/vm/runtime/sharedRuntime.cpp Thu Jan 31 09:41:34 2008 -0500 @@ -1481,11 +1481,9 @@ 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);