From d3a75f6c1a2372c9276a14cf7644df8bfec86bc7 Mon Sep 17 00:00:00 2001 From: Kevin Shanahan Date: Sun, 21 Apr 2013 10:17:37 +0930 Subject: [PATCH] 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 --- vis/vis.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/vis/vis.c b/vis/vis.c index 4cd64b9c..505ea918 100644 --- a/vis/vis.c +++ b/vis/vis.c @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -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; } }