Skip to content

Commit 272251f

Browse files
Add null check before strcmp
Adds a test that exercises this situation as well.
1 parent 42e255d commit 272251f

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

loader/settings.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,7 @@ TEST_FUNCTION_EXPORT VkResult get_settings_layers(const struct loader_instance*
973973
if (0 ==
974974
strncmp(settings_layers->list[j].info.layerName, newly_added_layer->info.layerName, VK_MAX_EXTENSION_NAME_SIZE)) {
975975
if (0 == (newly_added_layer->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER) &&
976+
settings_layers->list[j].lib_name != NULL && newly_added_layer->lib_name != NULL &&
976977
strcmp(settings_layers->list[j].lib_name, newly_added_layer->lib_name) == 0) {
977978
should_remove = true;
978979
break;

tests/loader_settings_tests.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,55 @@ TEST(SettingsFile, MetaLayerAlsoActivates) {
10011001
}
10021002
}
10031003

1004+
TEST(SettingsFile, DuplicateMetaLayers) {
1005+
FrameworkEnvironment env{};
1006+
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2)).add_physical_device({});
1007+
1008+
const char* explicit_layer_name = "VK_LAYER_Regular_TestLayer";
1009+
env.add_explicit_layer(
1010+
ManifestLayer{}.add_layer(
1011+
ManifestLayer::LayerDescription{}.set_name(explicit_layer_name).set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)),
1012+
"explicit_test_layer.json");
1013+
// Add an implicit layer and a meta layer that share a name
1014+
const char* meta_layer_name = "VK_LAYER_meta_layer";
1015+
env.add_implicit_layer(ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{}
1016+
.set_name(meta_layer_name)
1017+
.set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)
1018+
.set_disable_environment("NotGonnaWork")),
1019+
"implicit_layer.json");
1020+
env.add_implicit_layer(
1021+
ManifestLayer{}.set_file_format_version({1, 1, 2}).add_layer(ManifestLayer::LayerDescription{}
1022+
.set_name(meta_layer_name)
1023+
.add_component_layer(explicit_layer_name)
1024+
.set_disable_environment("NotGonnaWork")),
1025+
"meta_test_layer.json");
1026+
1027+
env.update_loader_settings(env.loader_settings.set_file_format_version({1, 0, 0}).add_app_specific_setting(
1028+
AppSpecificSettings{}
1029+
.add_stderr_log_filter("all")
1030+
.add_layer_configuration(LoaderSettingsLayerConfiguration{}
1031+
.set_name(explicit_layer_name)
1032+
.set_path(env.get_shimmed_layer_manifest_path(0))
1033+
.set_control("auto")
1034+
.set_treat_as_implicit_manifest(false))
1035+
.add_layer_configuration(LoaderSettingsLayerConfiguration{}.set_control("unordered_layer_location"))
1036+
.add_layer_configuration(
1037+
LoaderSettingsLayerConfiguration{}
1038+
.set_name(meta_layer_name)
1039+
.set_path(env.get_folder(ManifestLocation::implicit_layer).location() / "meta_test_layer.json")
1040+
.set_control("auto")
1041+
.set_treat_as_implicit_manifest(true))
1042+
.add_layer_configuration(LoaderSettingsLayerConfiguration{}
1043+
.set_name(meta_layer_name)
1044+
.set_path(env.get_shimmed_layer_manifest_path(1))
1045+
.set_control("auto")
1046+
.set_treat_as_implicit_manifest(true))
1047+
1048+
));
1049+
InstWrapper inst{env.vulkan_functions};
1050+
inst.CheckCreate();
1051+
}
1052+
10041053
// Layers are correctly ordered by settings file.
10051054
TEST(SettingsFile, LayerOrdering) {
10061055
FrameworkEnvironment env{};

0 commit comments

Comments
 (0)