From dcd0f46c0359192154c83de86ec0ca1f84e1a9d0 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sat, 22 Dec 2007 20:28:04 +0000 Subject: [PATCH] SILC_ERR_INVALID_ARGUMENT is return by silc_stack_realloc if the reallocation is not last allocation from stack. --- lib/silcutil/silcstack.c | 5 +++-- lib/silcutil/silcstack.h | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/silcutil/silcstack.c b/lib/silcutil/silcstack.c index 509331f2..88286d83 100644 --- a/lib/silcutil/silcstack.c +++ b/lib/silcutil/silcstack.c @@ -497,7 +497,7 @@ void *silc_stack_realloc(SilcStack stack, SilcUInt32 old_size, if (stack->stack->data[si]->bytes_left + old_size + ((unsigned char *)ptr - (unsigned char *)sptr) != bsize) { SILC_LOG_DEBUG(("Cannot reallocate")); - silc_set_errno_nofail(SILC_ERR_BAD_ADDRESS); + silc_set_errno_nofail(SILC_ERR_INVALID_ARGUMENT); SILC_STACK_STAT(stack, num_errors, 1); return NULL; } @@ -512,7 +512,8 @@ void *silc_stack_realloc(SilcStack stack, SilcUInt32 old_size, } SILC_LOG_DEBUG(("Cannot reallocate in this block")); - silc_set_errno_nofail(SILC_ERR_OUT_OF_MEMORY); + silc_set_errno_reason_nofail(SILC_ERR_TOO_LARGE_ALLOCATION, + "Cannot reallocate in this memory block"); SILC_STACK_STAT(stack, num_errors, 1); return NULL; } diff --git a/lib/silcutil/silcstack.h b/lib/silcutil/silcstack.h index 99d1c4ad..88032aa8 100644 --- a/lib/silcutil/silcstack.h +++ b/lib/silcutil/silcstack.h @@ -281,16 +281,17 @@ void *silc_stack_malloc(SilcStack stack, SilcUInt32 size); * SYNOPSIS * * void *silc_stack_realloc(SilcStack stack, SilcUInt32 old_size, - * *void *ptr, SilcUInt32 size); + * void *ptr, SilcUInt32 size); * * DESCRIPTION * * Attempts to reallocate memory by changing the size of the `ptr' into * `size'. This routine works only if the previous allocation to `stack' * was `ptr'. If there is another memory allocation between allocating - * `ptr' and this call this routine will return NULL. NULL is also - * returned if the `size' does not fit into the current stack block. - * If NULL is returned the old memory remains intact. + * `ptr' and this call this routine will return NULL (and silc_errno is + * set to SILC_ERR_INVALID_ARGUMENT). NULL is also returned if the `size' + * does not fit into the current stack block. If NULL is returned the old + * memory remains intact. * * NOTES * -- 2.24.0