diff options
author | eindenbom <eindenbom@gmail.com> | 2010-04-16 15:15:31 +0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-04-16 15:15:41 -0400 |
commit | d2934799b38e4a6d912a67bc685b362691b96c82 (patch) | |
tree | c90d246bf54f2d0b0fb3d890ff7c62971f972505 /src/util/util.h | |
parent | 51f72b7bb911a93859739905ba54de939c99dfb9 (diff) | |
download | sssd-d2934799b38e4a6d912a67bc685b362691b96c82.tar.gz sssd-d2934799b38e4a6d912a67bc685b362691b96c82.tar.xz sssd-d2934799b38e4a6d912a67bc685b362691b96c82.zip |
Avoid accessing half-deallocated memory when using talloc_zfree macro.
The correct memory deallocation sequence is:
- clear pointer to memory first
- then deallocate memory
Diffstat (limited to 'src/util/util.h')
-rw-r--r-- | src/util/util.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/util/util.h b/src/util/util.h index fae8096a9..0b691a7e6 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -118,7 +118,11 @@ errno_t set_debug_file_from_fd(const int fd); #define FLAGS_PID_FILE 0x0004 #ifndef talloc_zfree -#define talloc_zfree(ptr) do { talloc_free(ptr); ptr = NULL; } while(0) +#define talloc_zfree(ptr) do { \ + TALLOC_CTX *_tmp_ctx = ptr; \ + ptr = NULL; \ + talloc_free(_tmp_ctx); \ + } while(0) #endif #ifndef discard_const_p |