mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Fix several memleaks im cmd_ac.c
Exiting without freeing in some cases.
This commit is contained in:
parent
46ddf2c2f4
commit
27952cb16c
@ -1326,11 +1326,13 @@ cmd_ac_complete_filepath(const char *const input, char *const startstr, gboolean
|
|||||||
// expand ~ to $HOME
|
// expand ~ to $HOME
|
||||||
if (inpcp[0] == '~' && inpcp[1] == '/') {
|
if (inpcp[0] == '~' && inpcp[1] == '/') {
|
||||||
if (asprintf(&tmp, "%s/%sfoo", getenv("HOME"), inpcp+2) == -1) {
|
if (asprintf(&tmp, "%s/%sfoo", getenv("HOME"), inpcp+2) == -1) {
|
||||||
|
free(inpcp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
output_off = strlen(getenv("HOME"))+1;
|
output_off = strlen(getenv("HOME"))+1;
|
||||||
} else {
|
} else {
|
||||||
if (asprintf(&tmp, "%sfoo", inpcp) == -1) {
|
if (asprintf(&tmp, "%sfoo", inpcp) == -1) {
|
||||||
|
free(inpcp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1362,21 +1364,25 @@ cmd_ac_complete_filepath(const char *const input, char *const startstr, gboolean
|
|||||||
char *acstring;
|
char *acstring;
|
||||||
if (output_off) {
|
if (output_off) {
|
||||||
if (asprintf(&tmp, "%s/%s", directory, dir->d_name) == -1) {
|
if (asprintf(&tmp, "%s/%s", directory, dir->d_name) == -1) {
|
||||||
|
free(directory);
|
||||||
free(foofile);
|
free(foofile);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (asprintf(&acstring, "~/%s", tmp+output_off) == -1) {
|
if (asprintf(&acstring, "~/%s", tmp+output_off) == -1) {
|
||||||
|
free(directory);
|
||||||
free(foofile);
|
free(foofile);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
free(tmp);
|
free(tmp);
|
||||||
} else if (strcmp(directory, "/") == 0) {
|
} else if (strcmp(directory, "/") == 0) {
|
||||||
if (asprintf(&acstring, "/%s", dir->d_name) == -1) {
|
if (asprintf(&acstring, "/%s", dir->d_name) == -1) {
|
||||||
|
free(directory);
|
||||||
free(foofile);
|
free(foofile);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (asprintf(&acstring, "%s/%s", directory, dir->d_name) == -1) {
|
if (asprintf(&acstring, "%s/%s", directory, dir->d_name) == -1) {
|
||||||
|
free(directory);
|
||||||
free(foofile);
|
free(foofile);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user