Private
Public Access
2
0

mraa.c: Fix another memleak in mraa_find_i2c_bus_pci

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2016-11-04 13:36:53 +00:00
parent 3d790a8278
commit 92188ab950

View File

@@ -948,6 +948,10 @@ mraa_find_i2c_bus_pci(const char* pci_device, const char *pci_id, const char* ad
else {
while (n--) {
char* dup = strdup(namelist[n]->d_name);
if (dup == NULL) {
syslog(LOG_ERR, "Ran out of memory!");
break;
}
const char delim = '-';
char* token;
token = strsep(&dup, &delim);
@@ -969,6 +973,9 @@ mraa_find_i2c_bus_pci(const char* pci_device, const char *pci_id, const char* ad
return -1;
}
}
free(token);
} else {
free(dup);
}
free(namelist[n]);
}