diff --git a/libcli/security/util_sid.c b/libcli/security/util_sid.c index 2f3fceba228..2ab47f2db2c 100644 --- a/libcli/security/util_sid.c +++ b/libcli/security/util_sid.c @@ -337,12 +337,14 @@ int sid_compare_domain(const struct dom_sid *sid1, const struct dom_sid *sid2) NTSTATUS add_sid_to_array(TALLOC_CTX *mem_ctx, const struct dom_sid *sid, struct dom_sid **sids, uint32_t *num) { - *sids = talloc_realloc(mem_ctx, *sids, struct dom_sid, - (*num)+1); - if (*sids == NULL) { + struct dom_sid *tmp; + + tmp = talloc_realloc(mem_ctx, *sids, struct dom_sid, (*num)+1); + if (tmp == NULL) { *num = 0; return NT_STATUS_NO_MEMORY; } + *sids = tmp; sid_copy(&((*sids)[*num]), sid); *num += 1;