samples: Fixed some potential memory leaks. 21/168621/1
authorjoonbum.ko <joonbum.ko@samsung.com>
Mon, 29 Jan 2018 05:39:55 +0000 (14:39 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Mon, 29 Jan 2018 05:39:58 +0000 (14:39 +0900)
 - HANDLE_LEAK  WGID: 305107
 - MEMORY_LEAK  WGID: 305108, 305111

Change-Id: Ie81e0a3425c1119f834d466979edeb7d4a379899
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
samples/tri.c

index 396b7c3..97a5766 100644 (file)
@@ -134,6 +134,7 @@ dbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType,
         snprintf(message, sizeof(message), "WARNING: [%s] Code %d : %s",
                  pLayerPrefix, msgCode, pMsg);
     } else {
+        free(message);
         return false;
     }
 
@@ -1255,8 +1256,11 @@ char *demo_read_spv(const char *filename, size_t *psize) {
 
     shader_code = malloc(size);
     retVal = fread(shader_code, size, 1, fp);
-    if (!retVal)
+    if (!retVal) {
+        fclose(fp);
+        free(shader_code);
         return NULL;
+    }
 
     *psize = size;