From 2c2fb1151d497d64ab97f266454fa4f81a80e428 Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Sat, 31 Mar 2018 18:36:22 -0600 Subject: [PATCH] csa/match.c: coverity CID 87204; bad free; WTF --- cde/lib/csa/match.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cde/lib/csa/match.c b/cde/lib/csa/match.c index eb8947f5..a740ce10 100644 --- a/cde/lib/csa/match.c +++ b/cde/lib/csa/match.c @@ -220,6 +220,7 @@ _DtCmHashCriteria( } if (keep == B_TRUE) { + void *savedHattrs = NULL; if (*hattrs == NULL) { if ((*hattrs = (cms_attribute *)calloc(1, sizeof(cms_attribute)*(num_attrs-i)+ @@ -231,14 +232,15 @@ _DtCmHashCriteria( free(*hattrs); return (CSA_E_INSUFFICIENT_MEMORY); } else { + savedHattrs = (void *)*hattrs; *((char**)(*hattrs)) = (char *)&hval[0]; *hattrs = (cms_attribute *)\ ((char *)(*hattrs)+sizeof(char*)); } if (ops && (*hops = (CSA_enum *)calloc(1, sizeof(CSA_enum)*(num_attrs-i))) == NULL) { - free(*hattrs); free(hval); + free(savedHattrs); return (CSA_E_INSUFFICIENT_MEMORY); } } -- 2.25.1