Fix Integer Overflow
This commit is contained in:
parent
252a3f9d3b
commit
becf6aa58d
4
minmea.h
4
minmea.h
@ -260,6 +260,10 @@ static inline float minmea_tocoord(const struct minmea_float *f)
|
||||
{
|
||||
if (f->scale == 0)
|
||||
return NAN;
|
||||
if (f->scale > (INT_LEAST32_MAX / 100))
|
||||
return NAN;
|
||||
if (f->scale < (INT_LEAST32_MIN / 100))
|
||||
return NAN;
|
||||
int_least32_t degrees = f->value / (f->scale * 100);
|
||||
int_least32_t minutes = f->value % (f->scale * 100);
|
||||
return (float) degrees + (float) minutes / (60 * f->scale);
|
||||
|
Loading…
Reference in New Issue
Block a user