From fd458598cb619ec24ef0d00a47d84c790631257b Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Fri, 19 Feb 2016 16:18:02 +0100 Subject: [PATCH 1/2] TOOLS: Fix minor memory leak in sss_colondb_writeline The variable line was initialized to NULL. The we created temporary context tmp_ctx. We use talloc_asprintf_append to append string to line which is initially NULL and therefore new context which was not connected to tmp_ctx. man 3 talloc_string -> talloc_asprintf_append --- src/tools/common/sss_colondb.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tools/common/sss_colondb.c b/src/tools/common/sss_colondb.c index a1a52c552b949076bdedae58f275d29a176be1e6..e8aeb315c9ed0efde15553e2d741d04c5d895b1a 100644 --- a/src/tools/common/sss_colondb.c +++ b/src/tools/common/sss_colondb.c @@ -202,6 +202,13 @@ errno_t sss_colondb_writeline(struct sss_colondb *db, return ENOMEM; } + line = talloc_strdup(tmp_ctx, ""); + if (line == NULL) { + DEBUG(SSSDBG_CRIT_FAILURE, "talloc_new() failed.\n"); + ret = ENOMEM; + goto done; + } + for (i = 0; table[i].type != SSS_COLONDB_SENTINEL; i++) { switch (table[i].type) { case SSS_COLONDB_UINT32: -- 2.5.0