summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authoreindenbom <eindenbom@gmail.com>2010-04-16 15:15:31 +0400
committerStephen Gallagher <sgallagh@redhat.com>2010-04-16 15:15:34 -0400
commitff57c6aeb80a52b1f52bd1dac9308a69dc7a4774 (patch)
treef5fdc6e9ef185d790ced1fb4ebfd5eb74f82388a /src/util
parent264be69c7615a1f65a21805b95a9dbd2736d1fb4 (diff)
downloadsssd-ff57c6aeb80a52b1f52bd1dac9308a69dc7a4774.tar.gz
sssd-ff57c6aeb80a52b1f52bd1dac9308a69dc7a4774.tar.bz2
sssd-ff57c6aeb80a52b1f52bd1dac9308a69dc7a4774.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')
-rw-r--r--src/util/util.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/util/util.h b/src/util/util.h
index fae8096a..0b691a7e 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