diff options
author | Zack Middleton <zturtleman@gmail.com> | 2014-05-25 22:54:56 -0500 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2014-06-17 17:43:42 +0100 |
commit | 6e25879416dbbc710b205b5019fa0de5d952b1d2 (patch) | |
tree | 8d341091f6abe1daced07373be99c64209db0e6a | |
parent | f8618d2ed6c131d7c2a502c26f4a5f875899ae74 (diff) |
Fix OOB access in CM_EdgePlaneNum without erroring in CM_GridPlane
I changed warning to error in 9d74227559d46b85d0c43d395cd280d3de7ae8f4,
which broke JA's mp/ctf4 map and probably others.
-rw-r--r-- | src/qcommon/cm_patch.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/qcommon/cm_patch.c b/src/qcommon/cm_patch.c index d4c28eef..5a66b1b0 100644 --- a/src/qcommon/cm_patch.c +++ b/src/qcommon/cm_patch.c @@ -608,7 +608,7 @@ static int CM_GridPlane( int gridPlanes[MAX_GRID_SIZE][MAX_GRID_SIZE][2], int i, } // should never happen - Com_Error( ERR_DROP, "CM_GridPlane unresolvable" ); + Com_Printf( "WARNING: CM_GridPlane unresolvable\n" ); return -1; } @@ -627,6 +627,9 @@ static int CM_EdgePlaneNum( cGrid_t *grid, int gridPlanes[MAX_GRID_SIZE][MAX_GRI p1 = grid->points[i][j]; p2 = grid->points[i+1][j]; p = CM_GridPlane( gridPlanes, i, j, 0 ); + if ( p == -1 ) { + return -1; + } VectorMA( p1, 4, planes[ p ].plane, up ); return CM_FindPlane( p1, p2, up ); @@ -634,6 +637,9 @@ static int CM_EdgePlaneNum( cGrid_t *grid, int gridPlanes[MAX_GRID_SIZE][MAX_GRI p1 = grid->points[i][j+1]; p2 = grid->points[i+1][j+1]; p = CM_GridPlane( gridPlanes, i, j, 1 ); + if ( p == -1 ) { + return -1; + } VectorMA( p1, 4, planes[ p ].plane, up ); return CM_FindPlane( p2, p1, up ); @@ -641,6 +647,9 @@ static int CM_EdgePlaneNum( cGrid_t *grid, int gridPlanes[MAX_GRID_SIZE][MAX_GRI p1 = grid->points[i][j]; p2 = grid->points[i][j+1]; p = CM_GridPlane( gridPlanes, i, j, 1 ); + if ( p == -1 ) { + return -1; + } VectorMA( p1, 4, planes[ p ].plane, up ); return CM_FindPlane( p2, p1, up ); @@ -648,6 +657,9 @@ static int CM_EdgePlaneNum( cGrid_t *grid, int gridPlanes[MAX_GRID_SIZE][MAX_GRI p1 = grid->points[i+1][j]; p2 = grid->points[i+1][j+1]; p = CM_GridPlane( gridPlanes, i, j, 0 ); + if ( p == -1 ) { + return -1; + } VectorMA( p1, 4, planes[ p ].plane, up ); return CM_FindPlane( p1, p2, up ); @@ -655,6 +667,9 @@ static int CM_EdgePlaneNum( cGrid_t *grid, int gridPlanes[MAX_GRID_SIZE][MAX_GRI p1 = grid->points[i+1][j+1]; p2 = grid->points[i][j]; p = CM_GridPlane( gridPlanes, i, j, 0 ); + if ( p == -1 ) { + return -1; + } VectorMA( p1, 4, planes[ p ].plane, up ); return CM_FindPlane( p1, p2, up ); @@ -662,6 +677,9 @@ static int CM_EdgePlaneNum( cGrid_t *grid, int gridPlanes[MAX_GRID_SIZE][MAX_GRI p1 = grid->points[i][j]; p2 = grid->points[i+1][j+1]; p = CM_GridPlane( gridPlanes, i, j, 1 ); + if ( p == -1 ) { + return -1; + } VectorMA( p1, 4, planes[ p ].plane, up ); return CM_FindPlane( p1, p2, up ); |