Change-Id: I78fe3f4efc5723e93baf6227f9accb5a43d56f1a
*/
#include "default_backend.h"
*/
#include "default_backend.h"
pui_backend_ani_func *ani_func = NULL;
Eina_Hash *_animations_hash = NULL;
pui_backend_ani_func *ani_func = NULL;
Eina_Hash *_animations_hash = NULL;
_read_json_file(const char *path, int *data_size)
{
FILE *fp = fopen(path, "rb");
_read_json_file(const char *path, int *data_size)
{
FILE *fp = fopen(path, "rb");
- unsigned int size;
- char *buffer;
+ int size;
+ char *buffer = NULL;
ERROR_CHECK(fp, return NULL, "Failed to open file: %s\n", path);
fseek(fp, 0, SEEK_END);
ERROR_CHECK(fp, return NULL, "Failed to open file: %s\n", path);
fseek(fp, 0, SEEK_END);
- size = (unsigned int)ftell(fp);
+ size = (long int)ftell(fp);
+ ERROR_CHECK(0 < size && size < INT_MAX, goto error, "Invalid file: %d size\n", size);
buffer = (char *)calloc(sizeof(char), size + 1);
buffer = (char *)calloc(sizeof(char), size + 1);
+ ERROR_CHECK(buffer, goto error, "Failed to allocate memory for buffer\n");
if (fread(buffer, size, 1, fp) < 1) {
goto error;
if (fread(buffer, size, 1, fp) < 1) {
goto error;