Loader: fix open registry handle leak
Each handle returned by RegOpenKey*() API functions should be
closed using RegCloseKey().
This change fixes AppVerifier warning on leaklin HKEY objects.
diff --git a/loader/loader.c b/loader/loader.c
index d705100..0629d90 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -708,6 +708,7 @@
if (NULL == *reg_data) {
loader_log(inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"loaderGetRegistryFiles: Failed to allocate space for registry data for key %s", name);
+ RegCloseKey(key);
result = VK_ERROR_OUT_OF_HOST_MEMORY;
goto out;
}
@@ -720,6 +721,7 @@
inst, VK_DEBUG_REPORT_ERROR_BIT_EXT, 0,
"loaderGetRegistryFiles: Failed to reallocate space for registry value of size %d for key %s",
*reg_data_size * 2, name);
+ RegCloseKey(key);
result = VK_ERROR_OUT_OF_HOST_MEMORY;
goto out;
}
@@ -738,6 +740,7 @@
}
name_size = 2048;
}
+ RegCloseKey(key);
}
// Advance the location - if the next location is in the secondary hive, then reset the locations and advance the hive