Fix defect detected by static analysis tool 55/250855/2
authorInHong Han <inhong1.han@samsung.com>
Tue, 5 Jan 2021 07:14:33 +0000 (16:14 +0900)
committerInHong Han <inhong1.han@samsung.com>
Tue, 5 Jan 2021 07:31:50 +0000 (16:31 +0900)
Change-Id: If2fdcb684b69c968d1b8add326cb35e0414bffdb

sticker-parser/sticker-parser.c

index 063aa87..71b7a0d 100644 (file)
@@ -620,26 +620,30 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path
                 goto free_memory;
 
             char *rel_thumbnail = __get_string_from_object(info_object, "thumbnail");
-            if (rel_thumbnail && rel_thumbnail[0] != '\0') {
-                if (access(rel_thumbnail, F_OK) == 0) {
-                    thumbnail_path = __convert_sticker_uri(rel_thumbnail, appid, app_path);
-                } else {
-                    int len = strlen(app_path) + strlen(rel_thumbnail) + 2;
-                    char *new_thumbnail_path = (char *)calloc(len, sizeof(char));
-                    if (new_thumbnail_path) {
-                        if (rel_thumbnail[0] == '/')
-                            snprintf(new_thumbnail_path, len, "%s%s",app_path, rel_thumbnail);
-                        else
-                            snprintf(new_thumbnail_path, len, "%s%s%s",app_path, "/", rel_thumbnail);
-
-                        if (access(new_thumbnail_path, F_OK) == 0)
-                            thumbnail_path = __convert_sticker_uri(new_thumbnail_path, appid, app_path);
-
-                        free(new_thumbnail_path);
-                        new_thumbnail_path = NULL;
+            if (rel_thumbnail) {
+                if (rel_thumbnail[0] != '\0') {
+                    if (access(rel_thumbnail, F_OK) == 0) {
+                        thumbnail_path = __convert_sticker_uri(rel_thumbnail, appid, app_path);
+                    } else {
+                        int len = strlen(app_path) + strlen(rel_thumbnail) + 2;
+                        char *new_thumbnail_path = (char *)calloc(len, sizeof(char));
+                        if (new_thumbnail_path) {
+                            if (rel_thumbnail[0] == '/')
+                                snprintf(new_thumbnail_path, len, "%s%s",app_path, rel_thumbnail);
+                            else
+                                snprintf(new_thumbnail_path, len, "%s%s%s",app_path, "/", rel_thumbnail);
+
+                            if (access(new_thumbnail_path, F_OK) == 0)
+                                thumbnail_path = __convert_sticker_uri(new_thumbnail_path, appid, app_path);
+
+                            free(new_thumbnail_path);
+                            new_thumbnail_path = NULL;
+                        }
                     }
                 }
+
                 free(rel_thumbnail);
+                rel_thumbnail = NULL;
             }
 
             description = __get_string_from_object(info_object, "description");