[Scummvm-git-logs] scummvm master -> 2d8e0579eab1f4d69ccc36bf0f2071002539d5e8

sev- noreply at scummvm.org
Sun Nov 21 19:22:09 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
2d8e0579ea GRAPHICS: fix off-by-one errors when drawing a rounded rectangle


Commit: 2d8e0579eab1f4d69ccc36bf0f2071002539d5e8
    https://github.com/scummvm/scummvm/commit/2d8e0579eab1f4d69ccc36bf0f2071002539d5e8
Author: Benoit Pierre (benoit.pierre at gmail.com)
Date: 2021-11-21T20:22:06+01:00

Commit Message:
GRAPHICS: fix off-by-one errors when drawing a rounded rectangle

The code would create a rectangle of width+1 by weight+1, resulting
in buffer overflows when drawing at the bottom limit of a surface.

Changed paths:
    graphics/VectorRendererSpec.cpp


diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index df06b50c59..bd9f39fc6a 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -4140,9 +4140,9 @@ drawInteriorRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType colo
 	rsq = r*r;
 
 	PixelType *ptr_tl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + r);
-	PixelType *ptr_tr = (PixelType *)Base::_activeSurface->getBasePtr(x1 + w - r, y1 + r);
-	PixelType *ptr_bl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + h - r);
-	PixelType *ptr_br = (PixelType *)Base::_activeSurface->getBasePtr(x1 + w - r, y1 + h - r);
+	PixelType *ptr_tr = (PixelType *)Base::_activeSurface->getBasePtr(x1 + w - 1 - r, y1 + r);
+	PixelType *ptr_bl = (PixelType *)Base::_activeSurface->getBasePtr(x1 + r, y1 + h - 1 - r);
+	PixelType *ptr_br = (PixelType *)Base::_activeSurface->getBasePtr(x1 + w - 1 - r, y1 + h - 1 - r);
 	PixelType *ptr_fill = (PixelType *)Base::_activeSurface->getBasePtr(x1, y1);
 
 	int short_h = h - 2 * r;
@@ -4214,7 +4214,7 @@ drawInteriorRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType colo
 
 		ptr_fill += pitch * r;
 		while (short_h-- >= 0) {
-			colorFill<PixelType>(ptr_fill, ptr_fill + w + 1, color);
+			colorFill<PixelType>(ptr_fill, ptr_fill + w, color);
 			ptr_fill += pitch;
 		}
 	}




More information about the Scummvm-git-logs mailing list