From: Ian Lynagh Date: Thu, 11 Sep 2008 12:08:06 +0000 (+0000) Subject: In stgReallocForGMP, we need to copy min(old_size,new_size) X-Git-Tag: 2008-09-12~15 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=73f77be09896b041dc77ce31b349a89267e662c6 In stgReallocForGMP, we need to copy min(old_size,new_size) We used to always copy old_size --- diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c index a6134c6..8d237c1 100644 --- a/rts/sm/Storage.c +++ b/rts/sm/Storage.c @@ -926,12 +926,14 @@ stgAllocForGMP (size_t size_in_bytes) static void * stgReallocForGMP (void *ptr, size_t old_size, size_t new_size) { + size_t min_size; void *new_stuff_ptr = stgAllocForGMP(new_size); nat i = 0; char *p = (char *) ptr; char *q = (char *) new_stuff_ptr; - for (; i < old_size; i++, p++, q++) { + min_size = old_size < new_size ? old_size : new_size; + for (; i < min_size; i++, p++, q++) { *q = *p; }