kore

An easy to use, scalable and secure web application framework for writing web APIs in C.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 60ce2ce858435762066584459c154ac8a4058eb6
parent dca6e5818992565c7970593a6577738adde83e7d
Author: Joris Vink <joris@coders.se>
Date:   Mon, 22 Jul 2013 22:44:42 +0200

In kore_realloc() copy a minimum of old or new length bytes.

Diffstat:
src/mem.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/mem.c b/src/mem.c @@ -14,6 +14,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <sys/param.h> + #include <stdlib.h> #include "kore.h" @@ -79,7 +81,7 @@ kore_realloc(void *ptr, size_t len) fatal("kore_realloc(): magic boundary not found"); nptr = kore_malloc(len); - memcpy(nptr, ptr, KORE_MEMSIZE(ptr)); + memcpy(nptr, ptr, MIN(len, KORE_MEMSIZE(ptr))); kore_mem_free(ptr); }