fix some svase issues
[platform/core/uifw/libpui.git] / backends / default_backend.c
index ddd4463..390bfab 100644 (file)
@@ -205,26 +205,29 @@ static char *
 _read_json_file(const char *path, int *data_size)
 {
        FILE *fp = fopen(path, "rb");
-       int size;
+       unsigned int size;
        char *buffer;
        ERROR_CHECK(fp, return NULL, "Failed to open file: %s\n", path);
 
        fseek(fp, 0, SEEK_END);
-       size = ftell(fp);
+       size = (unsigned int)ftell(fp);
        fseek(fp, 0, SEEK_SET);
 
        buffer = (char *)calloc(sizeof(char), size + 1);
 
        if (fread(buffer, size, 1, fp) < 1) {
-               *data_size = 0;
-               free(buffer);
-               fclose(fp);
-               return NULL;
+               goto error;
        }
 
        *data_size = size;
        fclose(fp);
        return buffer;
+
+error:
+       *data_size = 0;
+       if (buffer) free(buffer);
+       fclose(fp);
+       return NULL;
 }
 
 static default_ani_info *
@@ -237,7 +240,7 @@ _read_json(const char *path)
        int data_size = 0, i, j;
 
        buffer = _read_json_file(path, &data_size);
-       ERROR_CHECK(buffer && data_size > 0, return EINA_FALSE, "File %s has no data\n", path);
+       ERROR_CHECK(buffer && data_size > 0, goto error, "File %s has no data\n", path);
        root_obj = json_tokener_parse(buffer);
        ERROR_CHECK(root_obj, goto error, "Failed to tokenize json object\n");
 
@@ -298,7 +301,7 @@ _read_json(const char *path)
        return ani_info;
 
 error:
-       free(buffer);
+       if (buffer) free(buffer);
        if (ani_info) {
                if (ani_info->frames) {
                        for (i = 0; i < ani_info->num_key_frames; i++) {