1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-23 21:45:30 +00:00

Fix several memleaks im cmd_ac.c

Exiting without freeing in some cases.
This commit is contained in:
Michael Vetter 2019-07-22 14:59:20 +02:00
parent 46ddf2c2f4
commit 27952cb16c

View File

@ -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;
}