1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-24 06:54:13 +00:00

csa/match.c: coverity CID 87204; bad free; WTF

This commit is contained in:
Jon Trulson 2018-03-31 18:36:22 -06:00
parent 7752966865
commit 2c2fb1151d

View file

@ -220,6 +220,7 @@ _DtCmHashCriteria(
} }
if (keep == B_TRUE) { if (keep == B_TRUE) {
void *savedHattrs = NULL;
if (*hattrs == NULL) { if (*hattrs == NULL) {
if ((*hattrs = (cms_attribute *)calloc(1, if ((*hattrs = (cms_attribute *)calloc(1,
sizeof(cms_attribute)*(num_attrs-i)+ sizeof(cms_attribute)*(num_attrs-i)+
@ -231,14 +232,15 @@ _DtCmHashCriteria(
free(*hattrs); free(*hattrs);
return (CSA_E_INSUFFICIENT_MEMORY); return (CSA_E_INSUFFICIENT_MEMORY);
} else { } else {
savedHattrs = (void *)*hattrs;
*((char**)(*hattrs)) = (char *)&hval[0]; *((char**)(*hattrs)) = (char *)&hval[0];
*hattrs = (cms_attribute *)\ *hattrs = (cms_attribute *)\
((char *)(*hattrs)+sizeof(char*)); ((char *)(*hattrs)+sizeof(char*));
} }
if (ops && (*hops = (CSA_enum *)calloc(1, if (ops && (*hops = (CSA_enum *)calloc(1,
sizeof(CSA_enum)*(num_attrs-i))) == NULL) { sizeof(CSA_enum)*(num_attrs-i))) == NULL) {
free(*hattrs);
free(hval); free(hval);
free(savedHattrs);
return (CSA_E_INSUFFICIENT_MEMORY); return (CSA_E_INSUFFICIENT_MEMORY);
} }
} }