Skip to content

Commit c939378

Browse files
committed
Fix use after free in CModManager::TryStart
1 parent 9a64f35 commit c939378

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Client/core/CModManager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ bool CModManager::TryStart()
165165
DWORD size = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, errorCode,
166166
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPSTR>(&buffer), 0, nullptr);
167167

168-
if (size > 0)
168+
if (buffer != nullptr && size > 0)
169169
{
170-
LocalFree(buffer);
171-
172170
std::string message{buffer, size};
173171
size_t length = message.find_last_not_of("\t\n\v\f\r ");
174172

173+
LocalFree(buffer);
174+
175175
if (length == std::string::npos)
176176
return false;
177177

0 commit comments

Comments
 (0)