Skip to content

Display and control your Android device

Fix possible division by zero

Romain Vimont85b55b3c4e3b
diff --git a/app/src/screen.c b/app/src/screen.c
index 2724a266..5b7a8808 100644
--- a/app/src/screen.c
+++ b/app/src/screen.c
@@ -488,6 +488,7 @@ sc_screen_show_initial_window(struct sc_screen *screen) {
}
SDL_ShowWindow(screen->window);
+ sc_screen_update_content_rect(screen);
}
void
@@ -848,6 +849,8 @@ sc_screen_convert_drawable_to_frame_coords(struct sc_screen *screen,
int32_t w = screen->content_size.width;
int32_t h = screen->content_size.height;
+ // screen->rect must be initialized to avoid a division by zero
+ assert(screen->rect.w && screen->rect.h);
x = (int64_t) (x - screen->rect.x) * w / screen->rect.w;
y = (int64_t) (y - screen->rect.y) * h / screen->rect.h;