From 1544cf006c1f9850f5b326923eaec7943a17d893 Mon Sep 17 00:00:00 2001 From: leitner Date: Tue, 14 Jul 2020 16:08:08 +0000 Subject: [PATCH] fix memory leak in error path --- cdb/cdb_make.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cdb/cdb_make.c b/cdb/cdb_make.c index c3c6937..0366f4a 100644 --- a/cdb/cdb_make.c +++ b/cdb/cdb_make.c @@ -46,9 +46,12 @@ int cdb_make_addend(struct cdb_make *c,unsigned long int keylen,unsigned long in head->hp[head->num].p = c->pos; ++head->num; ++c->numentries; - if (posplus(c,8) == -1) return -1; - if (posplus(c,keylen) == -1) return -1; - if (posplus(c,datalen) == -1) return -1; + if (posplus(c,8) == -1 || + posplus(c,keylen) == -1 || + posplus(c,datalen) == -1) { + free(head); + return -1; + } return 0; }