From b4114e345c52541855d0a319cdcf5bca1c29f1a7 Mon Sep 17 00:00:00 2001 From: "jiyong.min" Date: Wed, 25 Mar 2020 08:03:26 +0900 Subject: [PATCH] Fix memory leak in testsuite Change-Id: I773ec68db6e87dfebb9c528ec09018cc2fecf650 --- test/media-content_test.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/media-content_test.c b/test/media-content_test.c index 508eefa..8fc4103 100755 --- a/test/media-content_test.c +++ b/test/media-content_test.c @@ -2645,16 +2645,17 @@ int test_batch_operations() char *file_list[10]; for (i = 0; i < 10; i++) { - char filepath[255] = {0,}; - snprintf(filepath, sizeof(filepath), "%s%d.jpg", tzplatform_mkpath(TZ_USER_CONTENT, "test/image"), i+1); - media_content_debug("File : %s\n", filepath); - file_list[i] = strdup(filepath); + file_list[i] = g_strdup_printf("%s%d.jpg", tzplatform_mkpath(TZ_USER_CONTENT, "test/image"), i+1); + media_content_debug("File : %s\n", file_list[i]); } ret = media_info_insert_batch_to_db((const char **)file_list, 10, insert_batch_cb, NULL); if (ret != MEDIA_CONTENT_ERROR_NONE) media_content_error("media_info_insert_batch_to_db failed : %d\n", ret); + for (i = 0; i < 10; i++) + g_free(file_list[i]); + return ret; } -- 2.7.4