Skip to content

Commit

Permalink
Added data validation for color values
Browse files Browse the repository at this point in the history
  • Loading branch information
bakerds authored and BarbarossaTM committed Apr 17, 2023
1 parent 505020e commit 0b2ff64
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/WeatherMap.functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,15 @@ function myimagecolorallocate($image, $red, $green, $blue)
{
// it's possible that we're being called early - just return straight away, in that case
if(!isset($image)) return(-1);


// Make sure color values are in a sane range
if($red > 255) { $red = 255; }
if($green > 255) { $green = 255; }
if($blue > 255) { $blue = 255; }
if($red < 0) { $red = 0; }
if($green < 0) { $green = 0; }
if($blue < 0) { $blue = 0; }

$existing=imagecolorexact($image, $red, $green, $blue);

if ($existing > -1)
Expand Down

0 comments on commit 0b2ff64

Please sign in to comment.