Skip to content

Commit

Permalink
vkconfig3: Fix crash of layers with unknowned preset value
Browse files Browse the repository at this point in the history
Change-Id: I3481cd9e5e046eea1b885fc456c7c43000e3117d
  • Loading branch information
christophe-lunarg committed Nov 27, 2024
1 parent 4805449 commit 70175a8
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vkconfig_core/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,9 @@ void Layer::AddSettingData(SettingDataSet& settings_data, const QJsonValue& json
const std::string& key = ReadStringValue(json_setting_object, "key");

SettingMeta* setting_meta = FindSetting(this->settings, key.c_str());
if (setting_meta == nullptr) {
return;
}
assert(setting_meta);

SettingData* setting_data = setting_meta->Instantiate();
Expand Down
39 changes: 39 additions & 0 deletions vkconfig_core/test/layers/VK_LAYER_LUNARG_test_07.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"file_format_version": "1.2.0",
"layer": {
"name": "VK_LAYER_LUNARG_test_07",
"library_path": ".\\VkLayer_test.dll",
"api_version": "1.2.170",
"implementation_version": "Build 76",
"description": "Missing setting",
"platforms": [ "WINDOWS", "LINUX" ],
"status": "BETA",
"features": {
"presets": [
{
"label": "Preset Inherit",
"description": "Description Inherit",
"settings": [
{
"key": "int_required_only",
"value": 75
},
{
"key": "int_missing",
"value": 76
}
]
}
],
"settings": [
{
"key": "int_required_only",
"type": "INT",
"label": "Integer",
"description": "Integer Description",
"default": 82
}
]
}
}
}
1 change: 1 addition & 0 deletions vkconfig_core/test/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<file alias="VK_LAYER_LUNARG_test_04.json">./layers/VK_LAYER_LUNARG_test_04.json</file>
<file alias="VK_LAYER_LUNARG_test_05.json">./layers/VK_LAYER_LUNARG_test_05.json</file>
<file alias="VK_LAYER_LUNARG_test_06.json">./layers/VK_LAYER_LUNARG_test_06.json</file>
<file alias="VK_LAYER_LUNARG_test_07.json">./layers/VK_LAYER_LUNARG_test_07.json</file>

<file alias="VK_LAYER_LUNARG_version_135.json">./layers/VK_LAYER_LUNARG_version_135.json</file>
<file alias="VK_LAYER_LUNARG_version_193.json">./layers/VK_LAYER_LUNARG_version_193.json</file>
Expand Down
12 changes: 12 additions & 0 deletions vkconfig_core/test/test_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@ TEST(test_layer, load_setting_enum_interit) {
EXPECT_EQ(SETTING_VIEW_HIDDEN, setting_override->enum_values[1].view);
}

TEST(test_layer, load_setting_missing) {
Layer layer;
const LayerLoadStatus load_loaded = layer.Load(":/layers/VK_LAYER_LUNARG_test_07.json", LAYER_TYPE_EXPLICIT, false, Dummy());
EXPECT_EQ(load_loaded, LAYER_LOAD_ADDED);

EXPECT_EQ(Version(1, 2, 0), layer.file_format_version);
EXPECT_EQ(PLATFORM_WINDOWS_BIT | PLATFORM_LINUX_BIT, layer.platforms);
EXPECT_EQ(STATUS_BETA, layer.status);
EXPECT_EQ(1, layer.settings.size());
EXPECT_EQ(1, layer.presets.size());
}

TEST(test_layer, load_1_1_0_header) {
Layer layer;
const LayerLoadStatus load_loaded =
Expand Down

0 comments on commit 70175a8

Please sign in to comment.