summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Carnecky <tom@dbservice.com>2008-08-29 00:43:19 +0200
committerStephane Marchesin <marchesin@icps.u-strasbg.fr>2008-08-29 00:43:19 +0200
commitb460aeec3ea817540e43c8215f2cdf432c957289 (patch)
treeea50b84dca7ab7ddffb2b6b2c92abfe54a6ae2b8
parentbffbb497e2502b0aa6fd24804251d6a21d8fa034 (diff)
Fix drm_realloc when you're reallocing into something smaller.
-rw-r--r--bsd-core/drm_memory.c2
-rw-r--r--linux-core/drm_memory.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/bsd-core/drm_memory.c b/bsd-core/drm_memory.c
index 05343f3f..80891402 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 b90fc020..d1a88c88 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;