Permalink
Browse files

gsdx sw: init completely m_scanline buffer

The buffer contains extra room to avoid a segmentation fault due to an overflow.
Unfortunately the end of the buffer wasn't initialized which can lead to unexpected behavior.

Based on issue #1806 it could impact Guilty Gear X2
  • Loading branch information...
1 parent 2a2a022 commit 213fa1c1487dd688492144551ac534a1e3c2788e @gregory38 gregory38 committed Feb 8, 2017
Showing with 6 additions and 4 deletions.
  1. +6 −4 plugins/GSdx/GSRasterizer.cpp
@@ -52,11 +52,12 @@ GSRasterizer::GSRasterizer(IDrawScanline* ds, int id, int threads, GSPerfMon* pe
m_edge.buff = (GSVertexSW*)vmalloc(sizeof(GSVertexSW) * 2048, false);
m_edge.count = 0;
- m_scanline = (uint8*)_aligned_malloc((2048 >> m_thread_height) + 16, 64);
+ int rows = (2048 >> m_thread_height) + 16;
+ m_scanline = (uint8*)_aligned_malloc(rows, 64);
int row = 0;
- while(row < (2048 >> m_thread_height))
+ while(row < rows)
{
for(int i = 0; i < threads; i++, row++)
{
@@ -1143,11 +1144,12 @@ GSRasterizerList::GSRasterizerList(int threads, GSPerfMon* perfmon)
{
m_thread_height = compute_best_thread_height(threads);
- m_scanline = (uint8*)_aligned_malloc((2048 >> m_thread_height) + 16, 64);
+ int rows = (2048 >> m_thread_height) + 16;
+ m_scanline = (uint8*)_aligned_malloc(rows, 64);
int row = 0;
- while(row < (2048 >> m_thread_height))
+ while(row < rows)
{
for(int i = 0; i < threads; i++, row++)
{

0 comments on commit 213fa1c

Please sign in to comment.