Skip to content

Commit

Permalink
Break potential infinite loop in msProjectSegment (#4961)
Browse files Browse the repository at this point in the history
  • Loading branch information
szekerest committed Jul 23, 2014
1 parent fc99472 commit 54dda8c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions mapproject.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,18 @@ static int msProjectSegment( projectionObj *in, projectionObj *out,

testPoint = midPoint;

if( msProjectPoint( in, out, &testPoint ) == MS_FAILURE )
if( msProjectPoint( in, out, &testPoint ) == MS_FAILURE ) {
if (midPoint.x == subEnd.x && midPoint.y == subEnd.y)
return MS_FAILURE; /* break infinite loop */

subEnd = midPoint;
else
}
else {
if (midPoint.x == subStart.x && midPoint.y == subStart.y)
return MS_FAILURE; /* break infinite loop */

subStart = midPoint;
}
}

/* -------------------------------------------------------------------- */
Expand Down

0 comments on commit 54dda8c

Please sign in to comment.