about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-07-22 14:59:20 +0200
committerMichael Vetter <jubalh@iodoru.org>2019-07-22 14:59:20 +0200
commit27952cb16c142e89d18044d4e9986d5dc989d241 (patch)
treea9c07d93b8503cbea57929509d52975a74ded9c6 /src
parent46ddf2c2f4aaf1390b0924d880a2e7439509cf0b (diff)
downloadprofani-tty-27952cb16c142e89d18044d4e9986d5dc989d241.tar.gz
Fix several memleaks im cmd_ac.c
Exiting without freeing in some cases.
Diffstat (limited to 'src')
-rw-r--r--src/command/cmd_ac.c6
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;
                 }