Improve getting of xmp data 89/231589/1 accepted/tizen/unified/20200423.161052 submit/tizen/20200423.080104
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 23 Apr 2020 00:34:34 +0000 (09:34 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Thu, 23 Apr 2020 00:34:34 +0000 (09:34 +0900)
Change-Id: Icf42af7e90d32155912f3bdb3e38ebaf1cb75b2b
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/common/media-svc-util.c

index 02fc585a526228aea4b17a076c9506a9a4944a2d..48476730258ed20a537f8abc52913d88bcd6bfa2 100644 (file)
@@ -809,9 +809,8 @@ static int __image_360_check(const char *path)
        unsigned char exif_app1_xmp[2] = {0, };
        gsize exif_app1_xmp_size = 0;
        unsigned char exif_app1_xmp_t[2] = {0, };
-       char *xmp_data = NULL;
+       GString *xmp_data = NULL;
        int fdata = 0;
-       int temp = 0;
        int result = 0;
 
        memset(exif_header, 0x00, sizeof(exif_header));
@@ -842,7 +841,6 @@ static int __image_360_check(const char *path)
                        goto ERROR;
 
                if ((exif_app1_xmp[0] == 0xff) && (exif_app1_xmp[1] == 0xe1)) {
-                       char *ptr = NULL;
                        size = fread(exif_app1_xmp_t, 1, sizeof(exif_app1_xmp_t), fp);
                        if (size <= 0)
                                goto ERROR;
@@ -851,8 +849,7 @@ static int __image_360_check(const char *path)
                        if (exif_app1_xmp_size == 0)
                                goto ERROR;
 
-                       xmp_data = g_malloc(exif_app1_xmp_size);
-                       ptr = xmp_data;
+                       xmp_data = g_string_sized_new(exif_app1_xmp_size);
 
                        do {
                                exif_app1_xmp_size--;
@@ -861,20 +858,17 @@ static int __image_360_check(const char *path)
                                        continue;
                                if (fdata == '\0')
                                        continue;
-                               *ptr = (char)fdata;
-                               ptr++;
-                               temp++;
-                       } while (exif_app1_xmp_size > 0);
 
-                       ptr -= temp;
+                               xmp_data = g_string_append_c(xmp_data, (gchar)fdata);
+                       } while (exif_app1_xmp_size > 0);
 
-                       if (strstr(ptr, "UsePanoramaViewer")
-                       && strstr(ptr, "True")
-                       && strstr(ptr, "ProjectionType")
-                       && strstr(ptr, "equirectangular"))
+                       if (strstr(xmp_data->str, "UsePanoramaViewer") &&
+                               strstr(xmp_data->str, "True") &&
+                               strstr(xmp_data->str, "ProjectionType") &&
+                               strstr(xmp_data->str, "equirectangular"))
                                result = 1;
 
-                       g_free(xmp_data);
+                       g_string_free(xmp_data, TRUE);
                }
        }