Mercurial > hg > truffle
comparison src/share/vm/runtime/sharedRuntime.cpp @ 53:9785f6d2dd97
6631248: Memory problem when doing invalid type cast
Summary: Changed memory allocation method for exception method
Reviewed-by: ysr, never
author | kamg |
---|---|
date | Thu, 31 Jan 2008 09:41:34 -0500 |
parents | a61af66fc99e |
children | cd0742ba123c |
comparison
equal
deleted
inserted
replaced
1:92489cdc94d1 | 53:9785f6d2dd97 |
---|---|
1479 char* SharedRuntime::generate_class_cast_message( | 1479 char* SharedRuntime::generate_class_cast_message( |
1480 const char* objName, const char* targetKlassName) { | 1480 const char* objName, const char* targetKlassName) { |
1481 const char* desc = " cannot be cast to "; | 1481 const char* desc = " cannot be cast to "; |
1482 size_t msglen = strlen(objName) + strlen(desc) + strlen(targetKlassName) + 1; | 1482 size_t msglen = strlen(objName) + strlen(desc) + strlen(targetKlassName) + 1; |
1483 | 1483 |
1484 char* message = NEW_C_HEAP_ARRAY(char, msglen); | 1484 char* message = NEW_RESOURCE_ARRAY(char, msglen); |
1485 if (NULL == message) { | 1485 if (NULL == message) { |
1486 // out of memory - can't use a detailed message. Since caller is | 1486 // Shouldn't happen, but don't cause even more problems if it does |
1487 // using a resource mark to free memory, returning this should be | |
1488 // safe (caller won't explicitly delete it). | |
1489 message = const_cast<char*>(objName); | 1487 message = const_cast<char*>(objName); |
1490 } else { | 1488 } else { |
1491 jio_snprintf(message, msglen, "%s%s%s", objName, desc, targetKlassName); | 1489 jio_snprintf(message, msglen, "%s%s%s", objName, desc, targetKlassName); |
1492 } | 1490 } |
1493 return message; | 1491 return message; |