mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
libcli: Do not overwrite pointer on realloc failure
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
18332a1743
commit
a3737ef6bc
@ -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,
|
NTSTATUS add_sid_to_array(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
|
||||||
struct dom_sid **sids, uint32_t *num)
|
struct dom_sid **sids, uint32_t *num)
|
||||||
{
|
{
|
||||||
*sids = talloc_realloc(mem_ctx, *sids, struct dom_sid,
|
struct dom_sid *tmp;
|
||||||
(*num)+1);
|
|
||||||
if (*sids == NULL) {
|
tmp = talloc_realloc(mem_ctx, *sids, struct dom_sid, (*num)+1);
|
||||||
|
if (tmp == NULL) {
|
||||||
*num = 0;
|
*num = 0;
|
||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
*sids = tmp;
|
||||||
|
|
||||||
sid_copy(&((*sids)[*num]), sid);
|
sid_copy(&((*sids)[*num]), sid);
|
||||||
*num += 1;
|
*num += 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user