From: Tomas Carnecky Date: Thu, 28 Aug 2008 22:43:19 +0000 (+0200) Subject: Fix drm_realloc when you're reallocing into something smaller. X-Git-Tag: submit/1.0/20121108.012404~732 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b460aeec3ea817540e43c8215f2cdf432c957289;p=profile%2Fivi%2Flibdrm.git Fix drm_realloc when you're reallocing into something smaller. --- diff --git a/bsd-core/drm_memory.c b/bsd-core/drm_memory.c index 05343f3..8089140 100644 --- a/bsd-core/drm_memory.c +++ b/bsd-core/drm_memory.c @@ -69,7 +69,7 @@ void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area) if (pt == NULL) return NULL; if (oldpt && oldsize) { - memcpy(pt, oldpt, oldsize); + memcpy(pt, oldpt, DRM_MIN(oldsize,size)); free(oldpt, M_DRM); } return pt; diff --git a/linux-core/drm_memory.c b/linux-core/drm_memory.c index b90fc02..d1a88c8 100644 --- a/linux-core/drm_memory.c +++ b/linux-core/drm_memory.c @@ -183,7 +183,7 @@ void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area) if (!(pt = kmalloc(size, GFP_KERNEL))) return NULL; if (oldpt && oldsize) { - memcpy(pt, oldpt, oldsize); + memcpy(pt, oldpt, DRM_MIN(oldsize,size)); kfree(oldpt); } return pt;