summaryrefslogtreecommitdiff
path: root/src/gallium/include/pipe
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2008-03-24 12:50:28 -0600
committerBrian <brian.paul@tungstengraphics.com>2008-03-24 12:51:18 -0600
commit4e398df6825f4b6d568f055b689e7d7043e2785e (patch)
tree2662c89c831bde898ecd02a4c7667f1c9ff1fcc7 /src/gallium/include/pipe
parent48726e129a3727ec01e130835e74d62007093051 (diff)
gallium: fix REALLOC() to copy smaller of old/new sizes
Diffstat (limited to 'src/gallium/include/pipe')
-rw-r--r--src/gallium/include/pipe/p_util.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/gallium/include/pipe/p_util.h b/src/gallium/include/pipe/p_util.h
index 283f7fb8f5..505626c60b 100644
--- 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 );
}
}