Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8217441: Failure of ::realloc() should be handled correctly in sawind…
…bg.cpp

Reviewed-by: cjplummer, sspitsyn
  • Loading branch information
Alex Menkov committed Mar 13, 2020
1 parent c7e4b2a commit 3aeb2d1a514c708844cbc60aaa6f0c01eba96a00
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/jdk.hotspot.agent/windows/native/libsaproc/sawindbg.cpp
@@ -312,11 +312,13 @@ STDMETHODIMP SAOutputCallbacks::Output(THIS_
}
strcpy(m_msgBuffer, msg);
} else {
m_msgBuffer = (char*) realloc(m_msgBuffer, len + strlen(m_msgBuffer));
if (m_msgBuffer == 0) {
char* newBuffer = (char*)realloc(m_msgBuffer, len + strlen(m_msgBuffer));
if (newBuffer == nullptr) {
// old m_msgBuffer buffer is still valid
fprintf(stderr, "out of memory debugger output!\n");
return S_FALSE;
}
m_msgBuffer = newBuffer;
strcat(m_msgBuffer, msg);
}
return S_OK;

0 comments on commit 3aeb2d1

Please sign in to comment.