aboutsummaryrefslogtreecommitdiff
path: root/redist
diff options
context:
space:
mode:
authorJoshua Allen <axlecrusher@gmail.com>2017-03-08 21:08:30 -0500
committerJoshua Allen <axlecrusher@gmail.com>2017-03-08 21:08:30 -0500
commit26f55787820874629519c589f7c7c1ba1334ef54 (patch)
tree6bd955cba06c44cddd9ccf1d3cf4e53ab854dc38 /redist
parent4384e9850016e2117fda6e50499afec797993002 (diff)
downloadlibsurvive-26f55787820874629519c589f7c7c1ba1334ef54.tar.gz
libsurvive-26f55787820874629519c589f7c7c1ba1334ef54.tar.bz2
return null if no file is opened
Diffstat (limited to 'redist')
-rw-r--r--redist/json_helpers.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/redist/json_helpers.c b/redist/json_helpers.c
index b7ccb40..4a3ba55 100644
--- a/redist/json_helpers.c
+++ b/redist/json_helpers.c
@@ -76,6 +76,7 @@ uint32_t JSON_STRING_LEN;
char* load_file_to_mem(const char* path) {
FILE * f = fopen( path, "r" );
+ if (f==NULL) return NULL;
fseek( f, 0, SEEK_END );
int len = ftell( f );
fseek( f, 0, SEEK_SET );
@@ -116,7 +117,10 @@ static uint16_t json_load_array(const char* JSON_STRING, jsmntok_t* tokens, uint
void json_load_file(const char* path) {
uint32_t i = 0;
+
char* JSON_STRING = load_file_to_mem(path);
+ if (JSON_STRING==NULL) return;
+
JSON_STRING_LEN = strlen(JSON_STRING);
jsmn_parser parser;