aboutsummaryrefslogtreecommitdiff
path: root/loader
diff options
context:
space:
mode:
authorCourtney Goeltzenleuchter <courtneygo@google.com>2015-12-17 09:51:22 -0700
committerJon Ashburn <jon@lunarg.com>2015-12-17 12:18:53 -0700
commit7cbc1d169ff83faeb4dbd46c3b3f26f2ef6e8c93 (patch)
tree9df3cf37b4ecd69eaaec713a25e7470647abf786 /loader
parentd3cdaaf00f4295d3e095ddfa3713c9857ac3c139 (diff)
downloadusermoji-7cbc1d169ff83faeb4dbd46c3b3f26f2ef6e8c93.tar.xz
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.
Diffstat (limited to 'loader')
-rw-r--r--loader/loader.c8
1 files changed, 7 insertions, 1 deletions
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) {