CID:1214219 Resource leak

This commit is contained in:
Michael Jerris 2014-05-15 13:30:39 +00:00
parent 07b6bba68b
commit 179e07c649
1 changed files with 10 additions and 7 deletions

View File

@ -597,14 +597,14 @@ SWITCH_STANDARD_API(hash_dump_function)
mydata = strdup(cmd); mydata = strdup(cmd);
switch_assert(mydata); switch_assert(mydata);
argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
cmd = argv[0];
} else { } else {
realmvalue = "test"; realmvalue = "test";
realm = 0; realm = 0;
stream->write_function(stream, "Usage: "HASH_DUMP_SYNTAX"\n"); stream->write_function(stream, "Usage: "HASH_DUMP_SYNTAX"\n");
return SWITCH_STATUS_SUCCESS; goto done;
} }
cmd = strdup(argv[0]);
if (argc == 2) { if (argc == 2) {
realm = 1; realm = 1;
realmvalue = switch_mprintf("%s_", argv[1]); realmvalue = switch_mprintf("%s_", argv[1]);
@ -618,7 +618,7 @@ SWITCH_STANDARD_API(hash_dump_function)
mode = 2; mode = 2;
} else { } else {
stream->write_function(stream, "Usage: "HASH_DUMP_SYNTAX"\n"); stream->write_function(stream, "Usage: "HASH_DUMP_SYNTAX"\n");
return SWITCH_STATUS_SUCCESS; goto done;
} }
if (mode & 1) { if (mode & 1) {
@ -655,6 +655,9 @@ SWITCH_STANDARD_API(hash_dump_function)
switch_thread_rwlock_unlock(globals.db_hash_rwlock); switch_thread_rwlock_unlock(globals.db_hash_rwlock);
} }
done:
switch_safe_free(mydata);
switch_safe_free(realmvalue);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -723,9 +726,9 @@ SWITCH_STANDARD_API(hash_remote_function)
} }
done: done:
if (dup) {
free(dup); switch_safe_free(dup);
}
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }