Fix a memory leak on mesh_attr_text() error path
Should there not be enough room in the output buffer, the bss_basic_rate_set line would not be printed. This error case was handled otherwise, but the temporary memory allocation for building the information was not freed. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
d4c4ec9240
commit
c9bf7b6623
1 changed files with 4 additions and 3 deletions
|
@ -453,22 +453,23 @@ static int mesh_attr_text(const u8 *ies, size_t ies_len, char *buf, char *end)
|
||||||
ret = os_snprintf(pos, end - pos, "bss_basic_rate_set=%d",
|
ret = os_snprintf(pos, end - pos, "bss_basic_rate_set=%d",
|
||||||
bss_basic_rate_set[0]);
|
bss_basic_rate_set[0]);
|
||||||
if (os_snprintf_error(end - pos, ret))
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
goto fail;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
|
|
||||||
for (i = 1; i < bss_basic_rate_set_len; i++) {
|
for (i = 1; i < bss_basic_rate_set_len; i++) {
|
||||||
ret = os_snprintf(pos, end - pos, " %d",
|
ret = os_snprintf(pos, end - pos, " %d",
|
||||||
bss_basic_rate_set[i]);
|
bss_basic_rate_set[i]);
|
||||||
if (os_snprintf_error(end - pos, ret))
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
goto fail;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = os_snprintf(pos, end - pos, "\n");
|
ret = os_snprintf(pos, end - pos, "\n");
|
||||||
if (os_snprintf_error(end - pos, ret))
|
if (os_snprintf_error(end - pos, ret))
|
||||||
return pos - buf;
|
goto fail;
|
||||||
pos += ret;
|
pos += ret;
|
||||||
}
|
}
|
||||||
|
fail:
|
||||||
os_free(bss_basic_rate_set);
|
os_free(bss_basic_rate_set);
|
||||||
|
|
||||||
return pos - buf;
|
return pos - buf;
|
||||||
|
|
Loading…
Reference in a new issue