SparkFun_APDS-9960_Sensor_Arduino_Library icon indicating copy to clipboard operation
SparkFun_APDS-9960_Sensor_Arduino_Library copied to clipboard

Possible divide by 0 error

Open ShawnHymel opened this issue 9 years ago • 0 comments

Ratios in line 837 could possibly cause divide by 0 error if bounds check fails (line 785). Add a check beforehand to prevent this:

/* Catch to make sure we don't divide by 0 */
if( ((u_first + d_first) == 0) ||
    ((l_first + r_first) == 0) ||
    ((u_last + d_last) == 0) ||
    ((l_last + r_last) == 0) ) {

    return false;
}

ShawnHymel avatar Jan 26 '16 04:01 ShawnHymel