diff options
author | Michael Vetter <jubalh@iodoru.org> | 2019-07-22 14:59:20 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2019-07-22 14:59:20 +0200 |
commit | 27952cb16c142e89d18044d4e9986d5dc989d241 (patch) | |
tree | a9c07d93b8503cbea57929509d52975a74ded9c6 /src/command | |
parent | 46ddf2c2f4aaf1390b0924d880a2e7439509cf0b (diff) | |
download | profani-tty-27952cb16c142e89d18044d4e9986d5dc989d241.tar.gz |
Fix several memleaks im cmd_ac.c
Exiting without freeing in some cases.
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/cmd_ac.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index 619ec55d..5abee8be 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -1326,11 +1326,13 @@ cmd_ac_complete_filepath(const char *const input, char *const startstr, gboolean // expand ~ to $HOME if (inpcp[0] == '~' && inpcp[1] == '/') { if (asprintf(&tmp, "%s/%sfoo", getenv("HOME"), inpcp+2) == -1) { + free(inpcp); return NULL; } output_off = strlen(getenv("HOME"))+1; } else { if (asprintf(&tmp, "%sfoo", inpcp) == -1) { + free(inpcp); return NULL; } } @@ -1362,21 +1364,25 @@ cmd_ac_complete_filepath(const char *const input, char *const startstr, gboolean char *acstring; if (output_off) { if (asprintf(&tmp, "%s/%s", directory, dir->d_name) == -1) { + free(directory); free(foofile); return NULL; } if (asprintf(&acstring, "~/%s", tmp+output_off) == -1) { + free(directory); free(foofile); return NULL; } free(tmp); } else if (strcmp(directory, "/") == 0) { if (asprintf(&acstring, "/%s", dir->d_name) == -1) { + free(directory); free(foofile); return NULL; } } else { if (asprintf(&acstring, "%s/%s", directory, dir->d_name) == -1) { + free(directory); free(foofile); return NULL; } |