diff options
author | Arisotura <thetotalworm@gmail.com> | 2019-07-13 02:54:14 +0200 |
---|---|---|
committer | Arisotura <thetotalworm@gmail.com> | 2019-07-13 02:54:14 +0200 |
commit | 22f3cae0677d07033289689d536f4f515ea3274d (patch) | |
tree | 23b4addd4d547b3965234719b7955057f02e93a6 /src | |
parent | ff27036b3566d0c4215cacf09d44486d46cfc049 (diff) |
fix potential out-of-bounds write
Diffstat (limited to 'src')
-rw-r--r-- | src/GPU.cpp | 1 | ||||
-rw-r--r-- | src/GPU2D.cpp | 4 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/GPU.cpp b/src/GPU.cpp index dcd79b4..071d5f6 100644 --- a/src/GPU.cpp +++ b/src/GPU.cpp @@ -284,6 +284,7 @@ void SetDisplaySettings(bool accel) if (Framebuffer[1][0]) delete[] Framebuffer[1][0]; if (Framebuffer[0][1]) delete[] Framebuffer[0][1]; if (Framebuffer[1][1]) delete[] Framebuffer[1][1]; + Framebuffer[0][0] = new u32[fbsize]; Framebuffer[1][0] = new u32[fbsize]; Framebuffer[0][1] = new u32[fbsize]; diff --git a/src/GPU2D.cpp b/src/GPU2D.cpp index 3375d45..8998453 100644 --- a/src/GPU2D.cpp +++ b/src/GPU2D.cpp @@ -753,8 +753,10 @@ void GPU2D::DrawScanline(u32 line) case 1: // regular display { - for (int i = 0; i < stride; i+=2) + int i = 0; + for (; i < (stride & ~1); i+=2) *(u64*)&dst[i] = *(u64*)&BGOBJLine[i]; + if (stride & 1) dst[i] = BGOBJLine[i]; } break; |