Skip to content

Instantly share code, notes, and snippets.

@Dudemanguy
Last active March 12, 2024 01:44
Show Gist options
  • Save Dudemanguy/dac4eeb345916d8ede12fc43e679de92 to your computer and use it in GitHub Desktop.
Save Dudemanguy/dac4eeb345916d8ede12fc43e679de92 to your computer and use it in GitHub Desktop.
Simple patch for fixing an arthimetic exception that can occur when using the --scale flag in onscripter-en
diff --git a/resize_image.cpp b/resize_image.cpp
index af8866f..ecca1c4 100644
--- a/resize_image.cpp
+++ b/resize_image.cpp
@@ -203,7 +203,11 @@ void resizeImage( unsigned char *dst_buffer, int dst_width, int dst_height, int
x >>= 3;
//avoid resampling from outside the current cell
int ix = mx;
- if (((x+1)%cell_width)==0) ix = 0;
+ if (cell_width == 0) {
+ ix = 0;
+ } else if (((x+1)%cell_width)==0) {
+ ix = 0;
+ }
int k = tmp_total_width * y + x * byte_per_pixel;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment