fix issue with stacktrace_windows not allocating sufficient memory for SYMBOL_INFO struct (#334)

This commit is contained in:
Nicholas Lederer 2020-02-25 06:15:09 -08:00 committed by GitHub
parent 3ffc36a3a2
commit 9fb3e61e89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,7 +110,7 @@ namespace {
DWORD64 displacement64;
DWORD displacement;
char symbol_buffer[sizeof(SYMBOL_INFO) + 256];
char symbol_buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME];
SYMBOL_INFO *symbol = reinterpret_cast<SYMBOL_INFO *>(symbol_buffer);
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
symbol->MaxNameLen = MAX_SYM_NAME;
@ -120,7 +120,7 @@ namespace {
std::string lineInformation;
std::string callInformation;
if (SymFromAddr(GetCurrentProcess(), addr, &displacement64, symbol)) {
callInformation.append(" ").append({std::string(symbol->Name), symbol->NameLen});
callInformation.append(" ").append(std::string(symbol->Name, symbol->NameLen));
if (SymGetLineFromAddr64(GetCurrentProcess(), addr, &displacement, &line)) {
lineInformation.append("\t").append(line.FileName).append(" L: ");
lineInformation.append(std::to_string(line.LineNumber));