Skip to content

Commit 1655eaf

Browse files
committed
Do not use realloc(seap_msg->attrs, 0) to free seap_msg->attrs
This is implementation dependent, frown upon and triggering for sanitizers.
1 parent 54e8f62 commit 1655eaf

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/OVAL/probes/SEAP/seap-packet.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,14 @@ static int SEAP_packet_sexp2msg (SEXP_t *sexp_msg, SEAP_msg_t *seap_msg)
206206
_A(attr_i >= (SEXP_list_length (sexp_msg) - 4)/2);
207207

208208
seap_msg->attrs_cnt = attr_i;
209-
void *new_attrs = realloc(seap_msg->attrs, sizeof(SEAP_attr_t) * seap_msg->attrs_cnt);
210-
if (new_attrs != NULL || seap_msg->attrs_cnt == 0)
209+
if (seap_msg->attrs_cnt == 0) {
210+
free(seap_msg->attrs);
211+
seap_msg->attrs = NULL;
212+
} else {
213+
void *new_attrs = realloc(seap_msg->attrs, sizeof(SEAP_attr_t) * seap_msg->attrs_cnt);
211214
seap_msg->attrs = new_attrs;
215+
}
216+
212217
seap_msg->sexp = SEXP_list_last (sexp_msg);
213218

214219
return (0);

0 commit comments

Comments
 (0)