*/
#include "default_backend.h"
+#include <limits.h>
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");
- 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);
- size = (unsigned int)ftell(fp);
+ size = (long int)ftell(fp);
fseek(fp, 0, SEEK_SET);
+ ERROR_CHECK(0 < size && size < INT_MAX, goto error, "Invalid file: %d size\n", size);
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;