Fix memory leak in completion handler.

Coverty CID #56739

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2014-11-04 23:03:25 +01:00
parent 7cd7fc4b61
commit cd50714e29

View File

@ -1369,8 +1369,10 @@ static el_status_t c_complete(void)
len = strlen(p); len = strlen(p);
word = p; word = p;
new = q = malloc(sizeof(char) * (2 * len + 1)); new = q = malloc(sizeof(char) * (2 * len + 1));
if (!new) if (!new) {
free(word);
return CSstay; return CSstay;
}
while (*p) { while (*p) {
if ((*p < ' ' || strchr(SEPS, *p) != NULL) if ((*p < ' ' || strchr(SEPS, *p) != NULL)
&& (!unique || p[1] != 0)) { && (!unique || p[1] != 0)) {