From afcd1ff1c6c31b0e9c5ff3c27b1a0a7ea67667d7 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 2 Nov 2002 21:20:18 +0000 Subject: [PATCH] fix div/0 --- stepmania/src/SDL_dither.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stepmania/src/SDL_dither.cpp b/stepmania/src/SDL_dither.cpp index 97ad70680c..bfbe4e17bf 100644 --- a/stepmania/src/SDL_dither.cpp +++ b/stepmania/src/SDL_dither.cpp @@ -74,7 +74,11 @@ void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst) { int MaxInputIntensity = (1 << src_cbits[i])-1; int MaxOutputIntensity = (1 << dst_cbits[i])-1; - conv[i] = MaxOutputIntensity * 65536 / MaxInputIntensity; + /* If the source is missing the channel, avoid div/0. */ + if(MaxInputIntensity == 0) + conv[i] = 0; + else + conv[i] = MaxOutputIntensity * 65536 / MaxInputIntensity; } /* For each row: */