projects
/
mesa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
48726e1
)
gallium: fix REALLOC() to copy smaller of old/new sizes
author
Brian
<brian.paul@tungstengraphics.com>
Mon, 24 Mar 2008 18:50:28 +0000
(12:50 -0600)
committer
Brian
<brian.paul@tungstengraphics.com>
Mon, 24 Mar 2008 18:51:18 +0000
(12:51 -0600)
src/gallium/include/pipe/p_util.h
patch
|
blob
|
history
diff --git
a/src/gallium/include/pipe/p_util.h
b/src/gallium/include/pipe/p_util.h
index 283f7fb8f5dd588feb040a04c41b9ca1316c2f4b..505626c60b5bc2879913aa6266bc0761df3aa011 100644
(file)
--- a/
src/gallium/include/pipe/p_util.h
+++ b/
src/gallium/include/pipe/p_util.h
@@
-107,10
+107,10
@@
REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
void *new_ptr = NULL;
if (new_size != 0) {
+ unsigned copy_size = old_size < new_size ? old_size : new_size;
new_ptr = MALLOC( new_size );
-
- if( new_ptr && old_ptr ) {
- memcpy( new_ptr, old_ptr, old_size );
+ if (new_ptr && old_ptr && copy_size) {
+ memcpy( new_ptr, old_ptr, copy_size );
}
}