replmd: Make replmd_process_linked_attribute() mem dependencies clearer
authorTim Beale <timbeale@catalyst.net.nz>
Mon, 19 Nov 2018 21:59:40 +0000 (10:59 +1300)
committerTim Beale <timbeale@samba.org>
Wed, 21 Nov 2018 04:31:10 +0000 (05:31 +0100)
commita370f217bb94601345ad5700ea546259e1d04bfd
treeff4c81b75510a2637660ff6b46460d215b9a3fc2
parent05147d25e7b4a9343378c59927f443b723606960
replmd: Make replmd_process_linked_attribute() mem dependencies clearer

This patch should not alter functionality - it is just making memory
assumptions used in replmd_process_linked_attribute() clearer.

When adding/removing msg->elements we have to take care, as this will
invalidate things like the parsed-DN array or old ldb_message_element
pointers. This has always been the case (i.e. f6bc4c08b19f5615a49),
however, now we need to take even more care, as the msg being modified
is re-used and split across 2 different functions.

Add more code comments to highlight this. We can also free
pdn_list/old_el to prevent them being incorrectly used after realloc.
It seems appropriate to also add a sanity-check that the tmp_ctx alloc
succeeds (which all the other memory hangs off).

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Tim Beale <timbeale@samba.org>
Autobuild-Date(master): Wed Nov 21 05:31:10 CET 2018 on sn-devel-144
source4/dsdb/samdb/ldb_modules/repl_meta_data.c