From 0a5b68c4a15be7ac2c156a06cf6c55ca6b875c0d Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Tue, 14 Jul 2009 05:00:27 +0000 Subject: [PATCH] Forwardport r7822 by Buginator to trunk: Add ASSERT_OR_RETURN() to guard against buffer overflow. (Real fix is still needed, and the cause is the unit is trying to build in a invalid area, and the path finding needs to be reset for the droid) ref ticket:698 git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7845 4a71c877-e1ca-e34f-864e-861f7616d084 --- src/move.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/move.c b/src/move.c index 6360a27b9..47ceb5b7b 100644 --- a/src/move.c +++ b/src/move.c @@ -381,6 +381,7 @@ static BOOL moveDroidToBase(DROID *psDroid, UDWORD x, UDWORD y, BOOL bFormation) } else { + ASSERT_OR_RETURN(false, psDroid->sMove.numPoints > 0, "Invalid point count for path"); // align the formation with the last path of the route fmx2 = psDroid->sMove.asPath[psDroid->sMove.numPoints -1].x; fmy2 = psDroid->sMove.asPath[psDroid->sMove.numPoints -1].y; @@ -393,6 +394,7 @@ static BOOL moveDroidToBase(DROID *psDroid, UDWORD x, UDWORD y, BOOL bFormation) } else { + ASSERT_OR_RETURN(false, psDroid->sMove.numPoints > 1, "Invalid point count for path"); fmx1 = psDroid->sMove.asPath[psDroid->sMove.numPoints -2].x; fmy1 = psDroid->sMove.asPath[psDroid->sMove.numPoints -2].y; fmx1 = world_coord(fmx1) + TILE_UNITS / 2;