From e1e02d475f6c04a74c0bc956fef208520ffa30f4 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Wed, 5 Oct 2011 20:44:59 +1100 Subject: [PATCH] + added checks for NULL-pointers --- src/json2torrent.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/json2torrent.c b/src/json2torrent.c index a6e58a4..7a74d04 100644 --- a/src/json2torrent.c +++ b/src/json2torrent.c @@ -74,10 +74,19 @@ main(int argc, char **argv) /* FILE */ in = stdin; /* FILE */ out = stdout; - gen = yajl_gen_alloc(NULL); + if ((gen = yajl_gen_alloc(NULL)) == NULL) + { + fprintf(stderr, "Can't allocate json generator. Exiting."); + exit(EXIT_FAILURE); + } + yajl_gen_config(gen, yajl_gen_validate_utf8, 0); - handle = yajl_alloc(&callbacks, NULL, (void *) gen); + if ((handle = yajl_alloc(&callbacks, NULL, (void *) gen)) == NULL) + { + fprintf(stderr, "Can't allocate json parser. Exiting."); + exit(EXIT_FAILURE); + } yajl_config(handle, yajl_allow_comments, 1); yajl_config(handle, yajl_dont_validate_strings, 1);