]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Check max limit.
authorToni Wilen <twilen@winuae.net>
Sat, 2 Jan 2021 14:27:11 +0000 (16:27 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 2 Jan 2021 14:27:11 +0000 (16:27 +0200)
drawing.cpp

index c5851e9c5433a4378212290d6e76a3baefcba2eb..11cbba0cf55d9f468eb9817cdbc847bb5f73f663 100644 (file)
@@ -208,6 +208,7 @@ static uae_u8 all_zeros[MAX_PIXELS_PER_LINE];
 uae_u8 *xlinebuffer, *xlinebuffer_genlock;
 
 static int *amiga2aspect_line_map, *native2amiga_line_map;
+static int native2amiga_line_map_height;
 static uae_u8 **row_map;
 static uae_u8 *row_map_genlock_buffer;
 static uae_u8 row_tmp[MAX_PIXELS_PER_LINE * 32 / 8];
@@ -377,7 +378,7 @@ int coord_native_to_amiga_x (int x)
 
 int coord_native_to_amiga_y (int y)
 {
-       if (!native2amiga_line_map)
+       if (!native2amiga_line_map || y < 0 || y >= native2amiga_line_map_height)
                return -1;
        return native2amiga_line_map[y] + thisframe_y_adjust - minfirstline;
 }
@@ -2772,28 +2773,29 @@ static void init_aspect_maps(void)
                xfree (amiga2aspect_line_map);
 
        /* At least for this array the +1 is necessary. */
+       native2amiga_line_map_height = h;
        amiga2aspect_line_map = xmalloc (int, (MAXVPOS + 1) * 2 + 1);
-       native2amiga_line_map = xmalloc (int, h);
+       native2amiga_line_map = xmalloc (int, native2amiga_line_map_height);
 
        for (i = 0; i < maxl; i++) {
                int v = i - min_ypos_for_screen;
                if (v >= h && max_drawn_amiga_line < 0)
                        max_drawn_amiga_line = v;
-               if (i < min_ypos_for_screen || v >= h)
+               if (i < min_ypos_for_screen || v >= native2amiga_line_map_height)
                        v = -1;
                amiga2aspect_line_map[i] = v;
        }
        if (max_drawn_amiga_line < 0)
                max_drawn_amiga_line = maxl - min_ypos_for_screen;
 
-       for (i = 0; i < h; i++)
+       for (i = 0; i < native2amiga_line_map_height; i++)
                native2amiga_line_map[i] = -1;
 
        for (i = maxl - 1; i >= min_ypos_for_screen; i--) {
                int j;
                if (amiga2aspect_line_map[i] == -1)
                        continue;
-               for (j = amiga2aspect_line_map[i]; j < h && native2amiga_line_map[j] == -1; j++)
+               for (j = amiga2aspect_line_map[i]; j < native2amiga_line_map_height && native2amiga_line_map[j] == -1; j++)
                        native2amiga_line_map[j] = i >> linedbl;
        }
 }