diff --git a/src/conio/scale.c b/src/conio/scale.c
index 84dc1d75d86584ab9042e05a669ae088e9942cc1..f0e3d5064f0e2ca6ffab26978a862a3250e161a6 100644
--- a/src/conio/scale.c
+++ b/src/conio/scale.c
@@ -220,6 +220,9 @@ calc_scaling_factors(int *x, int *y, int winwidth, int winheight, int aspect_wid
 struct graphics_buffer *
 do_scale(struct rectlist* rect, int fwidth, int fheight)
 {
+	if (rect->rect.width == 0 || rect->rect.height == 0 || fwidth == 0 || fheight == 0)
+		return NULL;
+
 	struct graphics_buffer* ret1 = get_buffer();
 	struct graphics_buffer* ret2 = get_buffer();
 	int pointymult = 1;
@@ -237,9 +240,6 @@ do_scale(struct rectlist* rect, int fwidth, int fheight)
 	uint32_t* nt;
 	bool swapxy = false;
 
-	if (rect->rect.width == 0 || rect->rect.height == 0 || fwidth == 0 || fheight == 0)
-		return NULL;
-
 	int xscale = fwidth / rect->rect.width;
 	int yscale = fheight / rect->rect.height;