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)
return NULL;
if (oldpt && oldsize) {
memcpy(pt, oldpt, oldsize);
memcpy(pt, oldpt, DRM_MIN(oldsize,size));
free(oldpt, M_DRM);
}
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)))
return NULL;
if (oldpt && oldsize) {
memcpy(pt, oldpt, oldsize);
memcpy(pt, oldpt, DRM_MIN(oldsize,size));
kfree(oldpt);
}
return pt;