From 6935d1fdc300f139cf53ee157906ac7b43ef2633 Mon Sep 17 00:00:00 2001 From: rafagafe Date: Mon, 20 Mar 2017 02:36:26 +0100 Subject: [PATCH] Fix empty string as input. --- tiny-json.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiny-json.c b/tiny-json.c index 867cc2a..fb30922 100644 --- a/tiny-json.c +++ b/tiny-json.c @@ -47,7 +47,7 @@ static char* _setToNull( char* ch ); /* Parse a string to get a json. */ json_t const* json_create( char* str, json_t mem[], unsigned int qty ) { char* ptr = _goWhiteSpace( str ); - if ( *ptr != '{') return 0; + if ( !ptr || *ptr != '{' ) return 0; jsonPool_t pool = { .mem = mem, .qty = qty }; json_t* obj = _poolInit( &pool ); obj->name = 0;