Fix invalid memory access when a new driver is probing for hardware and the number of requested devices was already reached.

The probing functions assume that at least one device should be found and
passed to the caller, and only after finding such a device they will check that
they should eventually stop looking for more devices.  While we could make each
probing function capable of handling the special-case of finding 0 devices, it
is much more consistent to perform the check from the calling function.
This commit is contained in:
Romain Tartiere 2011-06-30 13:35:40 +00:00
parent fd19773c21
commit 84918fd075

View file

@ -154,6 +154,8 @@ nfc_list_devices (nfc_device_desc_t pnddDevices[], size_t szDevices, size_t * ps
if (ndr->probe (pnddDevices + (*pszDeviceFound), szDevices - (*pszDeviceFound), &szN)) {
*pszDeviceFound += szN;
DBG ("%ld device(s) found using %s driver", (unsigned long) szN, ndr->name);
if (*pszDeviceFound == szDevices)
break;
}
pndr++;
}