shithub: riscv

Download patch

ref: c92edc1de593873cffb8e4e5ce773020cde65ef3
parent: f7ab9fb52a0d50db3e5de67e74f1654ad374ae59
author: aiju <devnull@localhost>
date: Mon Mar 3 15:13:56 EST 2014

games/nes: fix buffer overrun

--- a/sys/src/games/nes/ppu.c
+++ b/sys/src/games/nes/ppu.c
@@ -310,7 +310,7 @@
 		mask = mem[PPUMASK];
 		if((mask & BGDISP) != 0)
 			drawbg();
-		if(((mask & BGDISP) == 0 && ppux <= 257 || ppux < 10 && (mask & BG8DISP) == 0) && ppux >= 2)
+		if((((mask & BGDISP) == 0 && ppux <= 257 || ppux < 10 && (mask & BG8DISP) == 0) && ppux >= 2) && ppuy != 261)
 			pixel(ppux - 2, ppuy, ppuread(0x3F00), 1);
 		if((mask & SPRITEDISP) != 0 && ppuy != 261)
 			drawsprites(ppux >= 10 || (mask & SPRITE8DISP) != 0);