The current implementation of talloc_zfree macro has a substantial deficiency: it deallocates memory first and then clears a pointer.
Clearing pointer after deallocation completes could lead to bad side effects when callbacks are called during object destruction: the callback called from destructor could dereference half-destroyed object referenced by the yet-not-cleared pointer.
The above could lead to disastrous effects including memory double free.
The patch attached fixes the issues by using correct free sequence: clear pointer first, then deallocate memory block.
Eugene