1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-12-22 14:30:45 +00:00

Use another pointer to retain the original address to free

This also resolves an issue where we weren't attempting to free the
duplicated string when returning early.
This commit is contained in:
Peter Evans 2018-03-13 11:00:44 -05:00
parent a243ed3d35
commit ed32f73e98

View File

@ -199,17 +199,18 @@ vm_debug_prompt()
void
vm_debug_execute(const char *str)
{
char *tok, *ebuf;
char *tok, *ebuf, *orig;
vm_debug_cmd *cmd;
vm_debug_args args;
ebuf = strdup(str);
orig = ebuf = strdup(str);
cmd = NULL;
tok = vm_debug_next_arg(&ebuf);
// No input
if (tok == NULL) {
free(orig);
return;
}
@ -217,6 +218,7 @@ vm_debug_execute(const char *str)
// No command found
if (cmd == NULL) {
free(orig);
return;
}
@ -236,6 +238,7 @@ vm_debug_execute(const char *str)
// But if this is -1, then something went wrong
if (args.addr2 == -1) {
free(orig);
return;
}
@ -246,6 +249,7 @@ vm_debug_execute(const char *str)
// Oh no
if (args.addr1 == -1) {
free(orig);
return;
}
@ -258,7 +262,7 @@ vm_debug_execute(const char *str)
cmd->handler(&args);
free(ebuf);
free(orig);
}
/*