From dd2e70c0799b302bc07b86f759afe9c0aaeda941 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Wed, 6 Apr 2016 20:49:02 +1200 Subject: loader: Don't scribble on caller memory in CreateInstance,CreateDevice expand_... / unexpand_... scribbled on both the CreateInfo struct and the list of layer strings, and then unscribbled them on the way back out. This is a lousy thing to do, and just blows up if the memory isn't writable (which it needn't be, given the API takes ptrs to const). Instead, copy the *CreateInfo into a shadow struct on the stack, and be careful in expand_layer_names never to scribble on the caller's layer names array. V2: slight tweak (missed initializer) Signed-off-by: Chris Forbes --- loader/loader.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'loader/loader.h') diff --git a/loader/loader.h b/loader/loader.h index 84f4d6fe..6c192a21 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -478,15 +478,13 @@ void loader_expand_layer_names( const struct loader_instance *inst, const char *key_name, uint32_t expand_count, const char expand_names[][VK_MAX_EXTENSION_NAME_SIZE], - uint32_t *layer_count, char ***ppp_layer_names); -void loader_unexpand_dev_layer_names(const struct loader_instance *inst, - uint32_t layer_count, char **layer_names, - char **layer_ptr, - const VkDeviceCreateInfo *pCreateInfo); -void loader_unexpand_inst_layer_names(const struct loader_instance *inst, - uint32_t layer_count, char **layer_names, - char **layer_ptr, - const VkInstanceCreateInfo *pCreateInfo); + uint32_t *layer_count, char const * const **ppp_layer_names); +void loader_delete_shadow_dev_layer_names(const struct loader_instance *inst, + const VkDeviceCreateInfo *orig, + VkDeviceCreateInfo *ours); +void loader_delete_shadow_inst_layer_names(const struct loader_instance *inst, + const VkInstanceCreateInfo *orig, + VkInstanceCreateInfo *ours); void loader_add_to_layer_list(const struct loader_instance *inst, struct loader_layer_list *list, uint32_t prop_list_count, -- cgit v1.2.3