rsys

Basic data structures and low-level features
git clone git://git.meso-star.fr/rsys.git
Log | Files | Refs | README | LICENSE

commit b390bf3b6cf70c417ad2f5fa2df0fa8e0461c68b
parent db025b52aa5a3d4d4f570ac7360d1ec5befe6f52
Author: vaplv <vaplv@free.fr>
Date:   Sat, 14 Dec 2013 15:27:57 +0100

Fix a memory issue in the default allocator dump function

Diffstat:
Msrc/mem_allocator.c | 2+-
Msrc/test_mem_allocator.c | 4++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mem_allocator.c b/src/mem_allocator.c @@ -193,7 +193,7 @@ default_dump dump_len = (size_t)len; if((size_t)len >= (max_dump_len - 1)) /* -1 <=> null char. */ - dump[max_dump_len] = '\0'; + dump[max_dump_len-1] = '\0'; return dump_len; #endif diff --git a/src/test_mem_allocator.c b/src/test_mem_allocator.c @@ -8,7 +8,7 @@ static void regular_test(struct mem_allocator* allocator) { - char dump[BUFSIZ]; + char dump[24]; void* p = NULL; void* q[3] = {NULL, NULL, NULL}; size_t i = 0; @@ -33,7 +33,7 @@ regular_test(struct mem_allocator* allocator) for(i = 0; i < 4; ++i) ((char*)p)[i] = (char)i; - MEM_DUMP(allocator, dump, BUFSIZ); + MEM_DUMP(allocator, dump, 24); printf("dump:\n%s\n", dump); MEM_DUMP(allocator, dump, 16); printf("truncated dump:\n%s\n", dump);