Skip to content

Commit

Permalink
Merge pull request #12365 from timetravelthree/master
Browse files Browse the repository at this point in the history
Fix out of bound write in EfbCopy::ClearEfb
  • Loading branch information
AdmiralCurtiss committed Dec 9, 2023
2 parents 7eb02ec + 3b8737d commit 515bd10
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Source/Core/VideoBackends/Software/EfbCopy.cpp
Expand Up @@ -3,6 +3,8 @@

#include "VideoBackends/Software/EfbCopy.h"

#include <algorithm>

#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Core/HW/Memmap.h"
Expand All @@ -11,6 +13,7 @@

#include "VideoCommon/BPMemory.h"
#include "VideoCommon/Fifo.h"
#include "VideoCommon/VideoCommon.h"

namespace EfbCopy
{
Expand All @@ -21,8 +24,8 @@ void ClearEfb()

int left = bpmem.copyTexSrcXY.x;
int top = bpmem.copyTexSrcXY.y;
int right = left + bpmem.copyTexSrcWH.x;
int bottom = top + bpmem.copyTexSrcWH.y;
int right = std::min(left + bpmem.copyTexSrcWH.x, EFB_WIDTH - 1);
int bottom = std::min(top + bpmem.copyTexSrcWH.y, EFB_HEIGHT - 1);

for (u16 y = top; y <= bottom; y++)
{
Expand Down

0 comments on commit 515bd10

Please sign in to comment.