Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2003 - 2006 Pekka Riikonen
+ Copyright (C) 2003 - 2008 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
{
int i;
+ if (!stack)
+ return;
+
silc_free(stack->frames);
for (i = 0; i < SILC_STACK_BLOCK_NUM; i++)
silc_free(stack->stack[i]);
/* Check that `ptr' is last allocation */
sptr = (unsigned char *)stack->stack[si] +
SILC_STACK_ALIGN(sizeof(**stack->stack), SILC_STACK_DEFAULT_ALIGN);
- if (stack->stack[si]->bytes_left + old_size + (ptr - sptr) != bsize) {
+ if (stack->stack[si]->bytes_left + old_size +
+ ((unsigned char *)ptr - (unsigned char *)sptr) != bsize) {
SILC_LOG_DEBUG(("Cannot reallocate"));
SILC_STACK_STAT(stack, num_errors, 1);
return NULL;