presets: Avoid string conversion on bad "name" type

This commit is contained in:
Tyler Yankee
2026-09-06 10:02:18 -04:00
parent 026c254a8e
commit af277fe06f
2 changed files with 15 additions and 1 deletions
+4 -1
View File
@@ -42,7 +42,10 @@ std::string getPresetName(cmJSONState* state)
{ {
Json::Value const* preset = getPreset(state); Json::Value const* preset = getPreset(state);
if (preset && preset->isMember("name")) { if (preset && preset->isMember("name")) {
return preset->operator[]("name").asString(); Json::Value const& name = preset->operator[]("name");
if (name.isConvertibleTo(Json::ValueType::stringValue)) {
return name.asString();
}
} }
return ""; return "";
} }
@@ -0,0 +1,11 @@
{
"version":6,
"configurePresets": [
{
"name": [],
"cacheVariables": {
"": {}
}
}
]
}