Fix memory leak when sending alerts checkoint (#15060)
* Free active_alerts and claim_id * Free digest context * Release memory unconditionally
Stelios Fragkakis committed
May 17, 2023 at 15:44 UTC
0973652cd5855f54f7ff89d79e3f36ede3d87cc0
2 files changed
+3
-1
database/sqlite/sqlite_aclk_alert.c
+2
@@ -1114,6 +1114,7 @@ void aclk_push_alarm_checkpoint(RRDHOST *host __maybe_unused)
1114
buffer_strcat(alarms_to_hash, "");
1115
len = 0;
1116
}
1117
+ freez(active_alerts);
1118
1119
char hash[SHA256_DIGEST_LENGTH + 1];
1120
if (hash256_string((const unsigned char *)buffer_tostring(alarms_to_hash), len, hash)) {
@@ -1126,6 +1127,7 @@ void aclk_push_alarm_checkpoint(RRDHOST *host __maybe_unused)
1127
alarm_checkpoint.checksum = (char *)hash;
1128
1129
aclk_send_provide_alarm_checkpoint(&alarm_checkpoint);
1130
+ freez(claim_id);
1131
log_access("ACLK RES [%s (%s)]: ALERTS CHECKPOINT SENT", wc->node_id, rrdhost_hostname(host));
1132
} else {
1133
log_access("ACLK RES [%s (%s)]: FAILED TO CREATE ALERTS CHECKPOINT HASH", wc->node_id, rrdhost_hostname(host));
libnetdata/libnetdata.c
+1
-1
@@ -2031,6 +2031,6 @@ int hash256_string(const unsigned char *string, size_t size, char *hash) {
2031
EVP_MD_CTX_destroy(ctx);
2032
return 0;
2033
}
2034
-
2034
+ EVP_MD_CTX_destroy(ctx);
2035
return 1;
2036
}