From 654953bc9a4bef79154a81fc6e3bc8518568e9c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rickard=20B=C3=A4ckman?= Date: Wed, 8 May 2013 11:21:56 +0200 Subject: [PATCH] 8008255: jvmtiExport.cpp::post_to_env() does not check malloc() return Reviewed-by: coleenp, dholmes, sla --- hotspot/src/share/vm/prims/jvmtiExport.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hotspot/src/share/vm/prims/jvmtiExport.cpp b/hotspot/src/share/vm/prims/jvmtiExport.cpp index ab66dca33d6..1e430e96b9a 100644 --- a/hotspot/src/share/vm/prims/jvmtiExport.cpp +++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp @@ -619,6 +619,9 @@ class JvmtiClassFileLoadHookPoster : public StackObj { // data has been changed by the new retransformable agent // and it hasn't already been cached, cache it *_cached_data_ptr = (unsigned char *)os::malloc(_curr_len, mtInternal); + if (*_cached_data_ptr == NULL) { + vm_exit_out_of_memory(_curr_len, OOM_MALLOC_ERROR, "unable to allocate cached copy of original class bytes"); + } memcpy(*_cached_data_ptr, _curr_data, _curr_len); *_cached_length_ptr = _curr_len; }