trace: Fix out-of-memory testing logic

data.function needs to be set for the return value to be of any use and
strcmp won't work with NULL pointer either. (CID 99907)

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2015-01-10 17:31:37 +02:00
parent c2096d9981
commit 8a42a076aa

View file

@ -272,9 +272,10 @@ size_t wpa_trace_calling_func(const char *buf[], size_t len)
data.found = FALSE;
bfd_map_over_sections(abfd, find_addr_sect, &data);
while (data.found || !data.function) {
if (pos > 0 ||
os_strcmp(data.function, __func__) != 0) {
while (data.found) {
if (data.function &&
(pos > 0 ||
os_strcmp(data.function, __func__) != 0)) {
buf[pos++] = data.function;
if (pos == len)
return pos;