From a1c356b49e7718828bf9473825a8f92db8353a4e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 17 Jun 2014 20:31:24 +0000 Subject: [PATCH] -bail out properly on error, fix leak --- src/namecache/test_namecache_api_cache_block.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/namecache/test_namecache_api_cache_block.c b/src/namecache/test_namecache_api_cache_block.c index f935ad159..ec3ddf0a9 100644 --- a/src/namecache/test_namecache_api_cache_block.c +++ b/src/namecache/test_namecache_api_cache_block.c @@ -195,11 +195,15 @@ run (void *cls, rd.flags = 0; memset ((char *) rd.data, 'a', TEST_RECORD_DATALEN); block = GNUNET_GNSRECORD_block_create (privkey, - GNUNET_TIME_UNIT_FOREVER_ABS, name, &rd, 1 ); + GNUNET_TIME_UNIT_FOREVER_ABS, + name, &rd, 1); if (NULL == block) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Namecache cannot cache no block\n")); + "Namecache cannot cache no block!\n"); + GNUNET_SCHEDULER_shutdown (); + GNUNET_free (block); + return; } nsh = GNUNET_NAMECACHE_connect (cfg); @@ -207,16 +211,21 @@ run (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Namecache cannot connect to namecache\n")); + GNUNET_SCHEDULER_shutdown (); + GNUNET_free (block); + return; } GNUNET_break (NULL != nsh); - nsqe = GNUNET_NAMECACHE_block_cache (nsh, block , &cache_cont, (void *) name); + nsqe = GNUNET_NAMECACHE_block_cache (nsh, + block, + &cache_cont, (void *) name); if (NULL == nsqe) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Namecache cannot cache no block\n")); } - + GNUNET_free (block); GNUNET_free ((void *)rd.data); } -- 2.25.1