diff options
Diffstat (limited to 'contrib/libucl/ucl_util.c')
-rw-r--r-- | contrib/libucl/ucl_util.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/contrib/libucl/ucl_util.c b/contrib/libucl/ucl_util.c index 11799ab1e..6f36e5e73 100644 --- a/contrib/libucl/ucl_util.c +++ b/contrib/libucl/ucl_util.c @@ -520,18 +520,23 @@ void ucl_chunk_free (struct ucl_chunk *chunk) { if (chunk) { - if (chunk->special_handler) { - if (chunk->special_handler->free_function) { - chunk->special_handler->free_function ( - (unsigned char *) chunk->begin, - chunk->end - chunk->begin, - chunk->special_handler->user_data); + struct ucl_parser_special_handler_chain *chain, *tmp; + + LL_FOREACH_SAFE (chunk->special_handlers, chain, tmp) { + if (chain->special_handler->free_function) { + chain->special_handler->free_function ( + chain->begin, + chain->len, + chain->special_handler->user_data); } else { - UCL_FREE (chunk->end - chunk->begin, - (unsigned char *) chunk->begin); + UCL_FREE (chain->len, chain->begin); } + + UCL_FREE (sizeof (*chain), chain); } + chunk->special_handlers = NULL; + if (chunk->fname) { free (chunk->fname); } |