summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-03-13 19:40:51 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:15:26 -0500
commitabafc0d88723d0fa86305375295fed9e7c896c96 (patch)
treec924c60ffe397cfe051778d3ae14b02ecafcb4bf /source3
parentbd1e853c19ddc0c731beb19d919e63e4df1fb0e0 (diff)
downloadsamba-abafc0d88723d0fa86305375295fed9e7c896c96.tar.gz
samba-abafc0d88723d0fa86305375295fed9e7c896c96.tar.bz2
samba-abafc0d88723d0fa86305375295fed9e7c896c96.zip
r14340: Fix coverity #78, resource leak in error path.
Jeremy. (This used to be commit 76c4f2c4dc6fcd91a350985b16f4a6a321ac4bf6)
Diffstat (limited to 'source3')
-rw-r--r--source3/rpcclient/rpcclient.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 8d70c6030a..4639b315d1 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -58,35 +58,43 @@ static char **completion_fn(const char *text, int start, int end)
#endif
/* make sure we have a list of valid commands */
- if (!commands)
+ if (!commands) {
return NULL;
+ }
matches = SMB_MALLOC_ARRAY(char *, MAX_COMPLETIONS);
- if (!matches) return NULL;
+ if (!matches) {
+ return NULL;
+ }
matches[count++] = SMB_STRDUP(text);
- if (!matches[0]) return NULL;
+ if (!matches[0]) {
+ SAFE_FREE(matches);
+ return NULL;
+ }
- while (commands && count < MAX_COMPLETIONS-1)
- {
- if (!commands->cmd_set)
+ while (commands && count < MAX_COMPLETIONS-1) {
+ if (!commands->cmd_set) {
break;
+ }
- for (i=0; commands->cmd_set[i].name; i++)
- {
+ for (i=0; commands->cmd_set[i].name; i++) {
if ((strncmp(text, commands->cmd_set[i].name, strlen(text)) == 0) &&
(( commands->cmd_set[i].returntype == RPC_RTYPE_NTSTATUS &&
commands->cmd_set[i].ntfn ) ||
( commands->cmd_set[i].returntype == RPC_RTYPE_WERROR &&
- commands->cmd_set[i].wfn)))
- {
+ commands->cmd_set[i].wfn))) {
matches[count] = SMB_STRDUP(commands->cmd_set[i].name);
- if (!matches[count])
+ if (!matches[count]) {
+ for (i = 0; i < count; i++) {
+ SAFE_FREE(matches[count]);
+ }
+ SAFE_FREE(matches);
return NULL;
+ }
count++;
}
}
-
commands = commands->next;
}