From: Jon Trulson Date: Sun, 1 Apr 2018 00:36:22 +0000 (-0600) Subject: csa/match.c: coverity CID 87204; bad free; WTF X-Git-Tag: 2.2.4a~156 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2c2fb1151d497d64ab97f266454fa4f81a80e428;p=oweals%2Fcde.git csa/match.c: coverity CID 87204; bad free; WTF --- 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); } }