From 88461c1cbd37df94d2934ec6b391a2e33f03509e Mon Sep 17 00:00:00 2001 From: ThePedroo Date: Sat, 23 Mar 2024 11:10:15 -0300 Subject: [PATCH] fix(rest_request): memory leak when using `reason` field This commit fixes a memory leak that happened when a reason was set for some request. --- src/discord-rest_request.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/discord-rest_request.c b/src/discord-rest_request.c index cad89f67..79c8c90f 100644 --- a/src/discord-rest_request.c +++ b/src/discord-rest_request.c @@ -256,7 +256,8 @@ discord_request_cancel(struct discord_requestor *rqtor, if (NOT_EMPTY_STR(req->reason)) { ua_conn_remove_header(req->conn, "X-Audit-Log-Reason"); - *req->reason = '\0'; + free(req->reason); + req->reason = NULL; } if (req->conn) { ua_conn_stop(req->conn);