Skip to content

Commit

Permalink
Quell divide-by-zero warning
Browse files Browse the repository at this point in the history
Coverity has been noting that `avg` might be zero when dividing. This is impossible.

Use assert() to quell the Coverity warning.

Closes CID 13801515
  • Loading branch information
GregoryLundberg committed Nov 30, 2017
1 parent 01ebfaf commit d9b88e2
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/sdl/utils.cpp
Expand Up @@ -1628,6 +1628,7 @@ surface blur_alpha_surface(const surface &surf, int depth)

p = lock.pixels() + y*res->w;
for(x = 0; x < res->w; ++x, ++p) {
assert(avg);
*p = (std::min(alpha/avg,ff) << 24) | (std::min(red/avg,ff) << 16) | (std::min(green/avg,ff) << 8) | std::min(blue/avg,ff);
if(x >= depth) {
alpha -= ((*front) >> 24)&0xFF;
Expand Down

0 comments on commit d9b88e2

Please sign in to comment.