Skip to content

Commit 7ec7f46

Browse files
committed
encode_splunk_hex: release context on exception (CID 507774)
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 93d0bbc commit 7ec7f46

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/cmt_encode_splunk_hec.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,14 +601,12 @@ static struct cmt_splunk_hec_context
601601
context = calloc(1, sizeof(struct cmt_splunk_hec_context));
602602
if (context == NULL) {
603603
result = CMT_ENCODE_SPLUNK_HEC_ALLOCATION_ERROR;
604-
605604
goto cleanup;
606605
}
607606

608607
/* host parameter is mandatory. */
609608
if (host == NULL) {
610609
result = CMT_ENCODE_SPLUNK_HEC_INVALID_ARGUMENT_ERROR;
611-
612610
goto cleanup;
613611
}
614612

@@ -634,7 +632,6 @@ static struct cmt_splunk_hec_context
634632
if (result != CMT_ENCODE_SPLUNK_HEC_SUCCESS) {
635633
if (context != NULL) {
636634
destroy_splunk_hec_context(context);
637-
638635
context = NULL;
639636
}
640637
}
@@ -664,6 +661,7 @@ cfl_sds_t cmt_encode_splunk_hec_create(struct cmt *cmt, const char *host,
664661
/* Allocate a 1KB of buffer */
665662
buf = cfl_sds_create_size(1024);
666663
if (!buf) {
664+
destroy_splunk_hec_context(context);
667665
return NULL;
668666
}
669667

0 commit comments

Comments
 (0)