projects
/
platform
/
core
/
uifw
/
libpui.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
default_backend: check return value of fseek
[platform/core/uifw/libpui.git]
/
backends
/
default_backend.c
diff --git
a/backends/default_backend.c
b/backends/default_backend.c
index
5d71cf2
..
135a194
100644
(file)
--- a/
backends/default_backend.c
+++ b/
backends/default_backend.c
@@
-206,14
+206,16
@@
static char *
_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");
- int size;
+ int size
, ret
;
char *buffer = NULL;
ERROR_CHECK(fp, return NULL, "Failed to open file: %s\n", path);
char *buffer = NULL;
ERROR_CHECK(fp, return NULL, "Failed to open file: %s\n", path);
- fseek(fp, 0, SEEK_END);
+ ret = fseek(fp, 0, SEEK_END);
+ ERROR_CHECK(ret == 0, goto error, "Failed to seek file. ret: %d\n", ret);
size = (long 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);
ERROR_CHECK(0 < size && size < INT_MAX, goto error, "Invalid file: %d size\n", size);
+ ret = fseek(fp, 0, SEEK_SET);
+ ERROR_CHECK(ret == 0, goto error, "Failed to seek file. ret: %d\n", ret);
buffer = (char *)calloc(sizeof(char), size + 1);
ERROR_CHECK(buffer, goto error, "Failed to allocate memory for buffer\n");
buffer = (char *)calloc(sizeof(char), size + 1);
ERROR_CHECK(buffer, goto error, "Failed to allocate memory for buffer\n");