sdcard: add trailing backslash only if path has no trailing backslash
authorChulHo Song <ch81.song@samsung.com>
Fri, 29 Jan 2016 07:31:30 +0000 (16:31 +0900)
committerChulHo Song <ch81.song@samsung.com>
Wed, 3 Feb 2016 02:16:44 +0000 (11:16 +0900)
Change-Id: I350f81df3c9ddc0408a21a1b5673ed0dcf8c378c
Signed-off-by: ChulHo Song <ch81.song@samsung.com>
(cherry picked from commit 47774e6252defe89cb31fbc06b684e134e3bbcde)

tizen/src/ecs/ecs_sdcard.c
tizen/src/emul_state.c

index 8f2e269cf945819373017518699cd697f16eafba..f70c406d47fe839ac643113c62a813c9f5cbc3c2 100644 (file)
@@ -57,6 +57,7 @@ static char* get_sdcard_full_path(char* sdcard_img_name, size_t dataLen) {
         g_strlcpy(sdcard_img_path, sdcard_path, MAXBUFLEN);
         g_strlcat(sdcard_img_path, sdcard_img_name, MAXBUFLEN);
         LOG_TRACE("sdcard img path: [%s] length: %d\n", sdcard_img_path, strlen(sdcard_img_path));
+        g_free((void*)sdcard_path);
         return sdcard_img_path;
     }
     return NULL;
index 8c910c109c7b614ff3e34c0a4db32d04ab0fdf23..a78b29b542d980c934c3fbd639ab537131db8056 100644 (file)
@@ -608,8 +608,16 @@ const char *get_sdcard_image_path(void)
 #ifndef CONFIG_WIN32
     const char *sdcard_path = g_strdup_printf("%s/", sdcard_abs_path);
 #else
-    const char *sdcard_path = g_strdup_printf("%s\\", sdcard_abs_path);
+    const char *sdcard_path;
+    int path_length = strnlen(sdcard_abs_path, sizeof(sdcard_abs_path));
+
+    if (sdcard_abs_path[path_length - 1] != '\\')
+        sdcard_path = g_strdup_printf("%s\\", sdcard_abs_path);
+    else
+        sdcard_path = g_strdup(sdcard_abs_path);
 #endif
+    g_free((void*)sdcard_rel_path);
+
     LOG_INFO("SD card path: %s\n", sdcard_path);
     return sdcard_path;
 }