adafruit / Adafruit_GPS

An interrupt-based GPS Arduino library for no-parsing-required use
Other
475 stars 318 forks source link

isEmpty() dereferences pointer before checking if it is NULL. #153

Open jpuderer opened 10 months ago

jpuderer commented 10 months ago

https://github.com/adafruit/Adafruit_GPS/blob/4005211fd4db7090d24d7409910d3ab764d63d7d/src/NMEA_parse.cpp#L851

I'm getting a crash in this library. I don't know if this is the root cause, but the logic in isEmpty is backwards.

The NULL check needs to happen before dereferencing the pointer.

Should be... if (pStart != NULL && ',' != *pStart && '*' != *pStart)