]> O.S.I.I.S - jp/vkvg.git/commitdiff
Fix a possible memory leak in vkengine_create (#62)
authorMarco Rubin <20150305+Rubo3@users.noreply.github.com>
Mon, 24 Jan 2022 11:44:55 +0000 (11:44 +0000)
committerGitHub <noreply@github.com>
Mon, 24 Jan 2022 11:44:55 +0000 (12:44 +0100)
* Fix a possible memory leak in vkengine_create

The assertion checks could crash the program, leaving memory allocated by `e` un`free`d.

* Restored GLFW callback function

tests/common/vkengine.c

index febc4845bccd531b57437ff8f1fc7b64c54b7e23..ec4746c99a284757637e18330043a00b5d211666 100644 (file)
@@ -111,8 +111,6 @@ bool instance_extension_supported (VkExtensionProperties* instanceExtProps, uint
 }
 
 vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR presentMode, uint32_t width, uint32_t height) {
-       vk_engine_t* e = (vk_engine_t*)calloc(1,sizeof(vk_engine_t));
-
        glfwSetErrorCallback(glfw_error_callback);
        assert (glfwInit()==GLFW_TRUE);
        assert (glfwVulkanSupported()==GLFW_TRUE);
@@ -147,6 +145,7 @@ vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR
 
        free(instanceExtProps);
 
+       vk_engine_t* e = (vk_engine_t*)calloc(1,sizeof(vk_engine_t));
        e->app = vkh_app_create(1 ,2 , "vkvgTest", enabledLayersCount, enabledLayers, enabledExtsCount, enabledExts);
 #if defined(DEBUG) && defined (VKVG_DBG_UTILS)
        vkh_app_enable_debug_messenger(e->app