From dbab4626ef9198326e27bbadb45bc125edaf7b93 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Thu, 10 Sep 2020 10:27:26 +0100 Subject: [PATCH] s3/libsmb: Cleanup parse_node_status() only set out params on success Signed-off-by: Noel Power Reviewed-by: Jeremy Allison --- source3/libsmb/namequery.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 7c16ec54bdd..f8093a0f6bd 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -335,18 +335,19 @@ static struct node_status *parse_node_status(TALLOC_CTX *mem_ctx, char *p, { struct node_status *ret; size_t i; + size_t result_count = 0; - *num_names = CVAL(p,0); + result_count = CVAL(p,0); - if (*num_names == 0) + if (result_count == 0) return NULL; - ret = talloc_array(mem_ctx, struct node_status,*num_names); + ret = talloc_array(mem_ctx, struct node_status,result_count); if (!ret) return NULL; p++; - for (i=0;i< *num_names;i++) { + for (i=0;i< result_count;i++) { strlcpy(ret[i].name,p,16); trim_char(ret[i].name,'\0',' '); ret[i].type = CVAL(p,15); @@ -361,6 +362,7 @@ static struct node_status *parse_node_status(TALLOC_CTX *mem_ctx, char *p, if (extra) { memcpy(&extra->mac_addr, p, 6); /* Fill in the mac addr */ } + *num_names = result_count; return ret; } -- 2.47.3