diff options
author | Volker Lendecke <vl@samba.org> | 2015-03-13 14:12:41 +0000 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2015-03-13 16:39:05 +0100 |
commit | c1e8bfb186c5cbeafbce9f2767db82edb579d5e1 (patch) | |
tree | a7df814d974e51be5c51eb658d165de6bc94ce80 /ctdb/server | |
parent | a8cc495b967935852c5357c3a4ef3d37579fb51b (diff) | |
download | samba-c1e8bfb186c5cbeafbce9f2767db82edb579d5e1.tar.gz |
ctdb: Fix memleak in ctdb_get_script_list
scandir allocates every name individually, see example code in susv4 or man
scandir
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'ctdb/server')
-rw-r--r-- | ctdb/server/eventscript.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c index 4cbb846ed9c..a47396a8ad9 100644 --- a/ctdb/server/eventscript.c +++ b/ctdb/server/eventscript.c @@ -177,8 +177,7 @@ static struct ctdb_scripts_wire *ctdb_get_script_list(struct ctdb_context *ctdb, + sizeof(scripts->scripts[0]) * count); if (scripts == NULL) { DEBUG(DEBUG_ERR, (__location__ " Failed to allocate scripts\n")); - free(namelist); - return NULL; + goto done; } scripts->num_scripts = count; @@ -191,6 +190,10 @@ static struct ctdb_scripts_wire *ctdb_get_script_list(struct ctdb_context *ctdb, } } +done: + for (i=0; i<count; i++) { + free(namelist[i]); + } free(namelist); return scripts; } |