Skip to content

Commit

Permalink
Fix div by zero in common-light.h
Browse files Browse the repository at this point in the history
RGBtoHSV() could cause a  div by zero if no color was detected. Thanks R
J McNamara for reporting it.
  • Loading branch information
botbench committed Feb 25, 2015
1 parent 5be6301 commit af33832
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/common-light.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void RGBtoHSV(float red, float green, float blue, float *hue, float *sat, float
float rgb_max = max3(red, green, blue);
float rgb_min;
*value = rgb_max / 2.56;
if (value == 0){
if ((value == 0) || (rgb_max == 0)){
*hue = -1;
*sat = -1;
return;
Expand Down

0 comments on commit af33832

Please sign in to comment.