diff options
author | Lukas Slebodnik <lslebodn@redhat.com> | 2016-02-19 16:18:02 +0100 |
---|---|---|
committer | Lukas Slebodnik <lslebodn@redhat.com> | 2016-02-24 13:50:52 +0100 |
commit | 6977d7c84145ac69195be58b3330861b9b8a3b72 (patch) | |
tree | 3f0cb67842b188c28ca67d10ad35a08182c9d62c /src/tools | |
parent | 74cc3797e311fd5dc12473678f499041ade7784f (diff) | |
download | sssd-6977d7c84145ac69195be58b3330861b9b8a3b72.tar.gz sssd-6977d7c84145ac69195be58b3330861b9b8a3b72.tar.xz sssd-6977d7c84145ac69195be58b3330861b9b8a3b72.zip |
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
Reviewed-by: Petr Cech <pcech@redhat.com>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/common/sss_colondb.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/tools/common/sss_colondb.c b/src/tools/common/sss_colondb.c index a41b12fb9..b9af5f7e5 100644 --- a/src/tools/common/sss_colondb.c +++ b/src/tools/common/sss_colondb.c @@ -198,6 +198,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: |