From 7cbc1d169ff83faeb4dbd46c3b3f26f2ef6e8c93 Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Thu, 17 Dec 2015 09:51:22 -0700 Subject: loader: correct compiler warning Fixed compiler warning of idx potentially being undefined. Also added test to check if the code took that path and return an error if that happens. --- loader/loader.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'loader') diff --git a/loader/loader.c b/loader/loader.c index 3f71cde8..4a83b492 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -2578,7 +2578,7 @@ static void loader_remove_layer_lib( struct loader_instance *inst, struct loader_layer_properties *layer_prop) { - uint32_t idx; + uint32_t idx = loader.loaded_layer_lib_count; struct loader_lib_info *new_layer_lib_list, *my_lib = NULL; for (uint32_t i = 0; i < loader.loaded_layer_lib_count; i++) { @@ -2590,6 +2590,12 @@ static void loader_remove_layer_lib( } } + if (idx == loader.loaded_layer_lib_count) { + loader_log(VK_DEBUG_REPORT_ERROR_BIT, 0, + "Unable to unref library %s", layer_prop->lib_name); + return; + } + if (my_lib) { my_lib->ref_count--; if (my_lib->ref_count > 0) { -- cgit v1.2.3