vis: use uintptr for FreeStackWinding index check

Just in case unsigned long isn't big enough to capture the pointer
offsets. Also, cast STACK_WINDINGS to the correct type before doing the
comparison.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
Kevin Shanahan 2013-04-21 10:17:37 +09:30
parent 97371bc6ab
commit d3a75f6c1a
1 changed files with 5 additions and 4 deletions

View File

@ -2,6 +2,7 @@
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#include <vis/leafbits.h>
#include <vis/vis.h>
@ -213,12 +214,12 @@ AllocStackWinding(pstack_t *stack)
void
FreeStackWinding(winding_t *w, pstack_t *stack)
{
unsigned long i = w - stack->windings;
uintptr_t index = w - stack->windings;
if (i < STACK_WINDINGS) {
if (stack->freewindings[i])
if (index < (uintptr_t)STACK_WINDINGS) {
if (stack->freewindings[index])
Error("%s: winding already freed", __func__);
stack->freewindings[i] = 1;
stack->freewindings[index] = 1;
}
}