diff options
author | Zack Middleton <zturtleman@gmail.com> | 2015-07-12 18:38:33 -0500 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2016-04-07 11:02:30 +0100 |
commit | cc17bca3ad04ab60cfc66c9a4b8f1188878ae802 (patch) | |
tree | 23c41bf7381c765403ab4dedcbed9074ebbca996 | |
parent | 3021d2b30e8d2b8456484cc9cd8adc30bda0a98e (diff) |
Fix range checks for numBorders in CM_AddFacetBevels
Found by Coverity.
-rw-r--r-- | src/qcommon/cm_patch.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/qcommon/cm_patch.c b/src/qcommon/cm_patch.c index 5a66b1b0..6fbcfbf6 100644 --- a/src/qcommon/cm_patch.c +++ b/src/qcommon/cm_patch.c @@ -877,7 +877,10 @@ void CM_AddFacetBevels( facet_t *facet ) { } if ( i == facet->numBorders ) { - if (facet->numBorders > 4 + 6 + 16) Com_Printf("ERROR: too many bevels\n"); + if ( facet->numBorders >= 4 + 6 + 16 ) { + Com_Printf( "ERROR: too many bevels\n" ); + continue; + } facet->borderPlanes[facet->numBorders] = CM_FindPlane2(plane, &flipped); facet->borderNoAdjust[facet->numBorders] = 0; facet->borderInward[facet->numBorders] = flipped; @@ -939,7 +942,10 @@ void CM_AddFacetBevels( facet_t *facet ) { } if ( i == facet->numBorders ) { - if (facet->numBorders > 4 + 6 + 16) Com_Printf("ERROR: too many bevels\n"); + if ( facet->numBorders >= 4 + 6 + 16 ) { + Com_Printf( "ERROR: too many bevels\n" ); + continue; + } facet->borderPlanes[facet->numBorders] = CM_FindPlane2(plane, &flipped); for ( k = 0 ; k < facet->numBorders ; k++ ) { @@ -977,6 +983,10 @@ void CM_AddFacetBevels( facet_t *facet ) { #ifndef BSPC //add opposite plane + if ( facet->numBorders >= 4 + 6 + 16 ) { + Com_Printf( "ERROR: too many bevels\n" ); + return; + } facet->borderPlanes[facet->numBorders] = facet->surfacePlane; facet->borderNoAdjust[facet->numBorders] = 0; facet->borderInward[facet->numBorders] = qtrue; |