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

This commit is contained in:
Joris Vink 2013-07-22 22:44:42 +02:00
parent dca6e58189
commit 60ce2ce858
1 changed files with 3 additions and 1 deletions

View File

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