From 26f55787820874629519c589f7c7c1ba1334ef54 Mon Sep 17 00:00:00 2001 From: Joshua Allen Date: Wed, 8 Mar 2017 21:08:30 -0500 Subject: return null if no file is opened --- redist/json_helpers.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'redist') 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; -- cgit v1.2.3