Merge pull request #568 from rsfbarreira/patch-1

Fix undefined behavior in FreeStackWinding
This commit is contained in:
Timothee "TTimo" Besset 2018-01-07 13:01:27 -06:00 committed by GitHub
commit fe4fbe25a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -116,16 +116,15 @@ fixedWinding_t *AllocStackWinding( pstack_t *stack ){
void FreeStackWinding( fixedWinding_t *w, pstack_t *stack ){
int i;
i = w - stack->windings;
if ( i < 0 || i > 2 ) {
return; // not from local
for (i = 0; i < sizeof(stack->windings) / sizeof(stack->windings[0]); i++) {
if (w == &stack->windings[i]) {
if ( stack->freewindings[i] ) {
Error( "FreeStackWinding: already free" );
}
stack->freewindings[i] = 1;
break;
}
}
if ( stack->freewindings[i] ) {
Error( "FreeStackWinding: allready free" );
}
stack->freewindings[i] = 1;
}
/*