diff --git a/minmea.h b/minmea.h index 91568f7..893e6c8 100644 --- a/minmea.h +++ b/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);