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:
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);
}