mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
cmJSONState: Avoid UB on empty error message
The caller for `GetErrorMessage` _should_ only be calling this method if there actual errors (i.e., `!errors.empty()`). However, in the incidental absence of the intended usage, avoid `pop_back` on an empty string.
This commit is contained in:
@@ -78,7 +78,9 @@ std::string cmJSONState::GetErrorMessage(bool showContext)
|
||||
message = cmStrCat(message, GetJsonContext(loc), '\n');
|
||||
}
|
||||
}
|
||||
message.pop_back();
|
||||
if (!message.empty()) {
|
||||
message.pop_back();
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user