Skip to content

Commit 7a70eeb

Browse files
committed
Fix divide by zero error
1 parent 0ca9892 commit 7a70eeb

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Classes/ImageFilter.m

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ void filterSepia(UInt8 *pixelBuf, UInt32 offset, void *context)
115115
void filterPosterize(UInt8 *pixelBuf, UInt32 offset, void *context)
116116
{
117117
int levels = *((int*)context);
118+
if (levels == 0) levels = 1; // avoid divide by zero
118119
int step = 255 / levels;
119120

120121
int r = offset;

0 commit comments

Comments
 (0)