From cb638a3453971f259fcd84eae0a5fa4ae08bea8b Mon Sep 17 00:00:00 2001 From: Maya Rashish Date: Thu, 9 Mar 2017 18:35:25 +0200 Subject: [PATCH] Only free ctx->rhs if allocating ctx succeeded. Also, we don't need to null-test prior to a free call, it is fine by C99. so get rid of those tests. --- src/lib/hesiod.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/lib/hesiod.c b/src/lib/hesiod.c index 2738713..3c29f41 100644 --- a/src/lib/hesiod.c +++ b/src/lib/hesiod.c @@ -144,16 +144,13 @@ int hesiod_init(void **context) else return 0; } + free(ctx->lhs); + free(ctx->rhs); + free(ctx); } else errno = ENOMEM; - if (ctx->lhs) - free(ctx->lhs); - if (ctx->rhs) - free(ctx->rhs); - if (ctx) - free(ctx); return -1; }