Fix drm_realloc when you're reallocing into something smaller.

main
Tomas Carnecky 2008-08-29 00:43:19 +02:00 committed by Stephane Marchesin
parent bffbb497e2
commit b460aeec3e
2 changed files with 2 additions and 2 deletions

View File

@ -69,7 +69,7 @@ void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
if (pt == NULL) if (pt == NULL)
return NULL; return NULL;
if (oldpt && oldsize) { if (oldpt && oldsize) {
memcpy(pt, oldpt, oldsize); memcpy(pt, oldpt, DRM_MIN(oldsize,size));
free(oldpt, M_DRM); free(oldpt, M_DRM);
} }
return pt; return pt;

View File

@ -183,7 +183,7 @@ void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
if (!(pt = kmalloc(size, GFP_KERNEL))) if (!(pt = kmalloc(size, GFP_KERNEL)))
return NULL; return NULL;
if (oldpt && oldsize) { if (oldpt && oldsize) {
memcpy(pt, oldpt, oldsize); memcpy(pt, oldpt, DRM_MIN(oldsize,size));
kfree(oldpt); kfree(oldpt);
} }
return pt; return pt;