Private
Public Access
2
0

firmata.c: fix possible crash if devs is wrong

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2016-03-11 16:36:40 +00:00
parent 5789f5001d
commit 91452e5c83
2 changed files with 7 additions and 3 deletions

View File

@@ -245,9 +245,9 @@ firmata_endParse(t_firmata* firmata)
printf("i2c reply is %d\n", firmata->i2cmsg[addr][reg]);
#endif
} else {
struct _firmata* devs = firmata->devs[0];
int i = 0;
if (devs != NULL) {
if (firmata->devs != NULL) {
struct _firmata* devs = firmata->devs[0];
int i = 0;
for (i; i < firmata->dev_count; i++, devs++) {
if (devs != NULL) {
if (firmata->parse_buff[1] == devs->feature) {

View File

@@ -464,6 +464,10 @@ mraa_firmata_plat_init(const char* uart_dev)
}
firmata_dev = firmata_new(uart_dev);
if (firmata_dev == NULL) {
free(b);
return NULL;
}
// if this isn't working then we have an issue with our uart
while (!firmata_dev->isReady) {