diff options
author | Michael Adam <obnox@samba.org> | 2008-01-09 01:34:21 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2008-02-11 15:07:46 +0100 |
commit | af406133c1aa736d6c2c8327cdc0f39b7592df92 (patch) | |
tree | 17c878a8668444f6c7ad1130780839e6f7b3950d /source4/lib/talloc | |
parent | 44cb6a81f26aed44a5bdc383ad59c5fbd2789262 (diff) | |
download | samba-af406133c1aa736d6c2c8327cdc0f39b7592df92.tar.gz samba-af406133c1aa736d6c2c8327cdc0f39b7592df92.tar.bz2 samba-af406133c1aa736d6c2c8327cdc0f39b7592df92.zip |
Fix talloctort: move size check after referenced ptr check.
Michael
(This used to be commit a0caedb94f6f7c62ae706e35a4c0b2876f74978d)
Diffstat (limited to 'source4/lib/talloc')
-rw-r--r-- | source4/lib/talloc/talloc.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/source4/lib/talloc/talloc.c b/source4/lib/talloc/talloc.c index 7aad42ce8c..9e141ab5fd 100644 --- a/source4/lib/talloc/talloc.c +++ b/source4/lib/talloc/talloc.c @@ -787,16 +787,16 @@ void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *n tc = talloc_chunk_from_ptr(ptr); - if ((size < tc->size) && ((tc->size - size) < 1024)) { - tc->size = size; - return ptr; - } - /* don't allow realloc on referenced pointers */ if (unlikely(tc->refs)) { return NULL; } + if ((size < tc->size) && ((tc->size - size) < 1024)) { + tc->size = size; + return ptr; + } + /* by resetting magic we catch users of the old memory */ tc->flags |= TALLOC_FLAG_FREE; |