From 654a489f49f0fa1cb156be417e0ce86869d7fea0 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sat, 18 Mar 2023 10:32:49 +0900 Subject: [PATCH] Fix memory leaks in debugger_dap.c --- src/debugger_dap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/debugger_dap.c b/src/debugger_dap.c index 9b93351..ebc917e 100644 --- a/src/debugger_dap.c +++ b/src/debugger_dap.c @@ -72,7 +72,7 @@ static void send_json(cJSON *json) { printf("Content-Length: %zu\r\n\r\n%s", strlen(str), str); fflush(stdout); free(str); - cJSON_free(json); + cJSON_Delete(json); } static void emit_initialized_event(void) { @@ -494,7 +494,7 @@ static boolean handle_request(cJSON *request) { if (!cJSON_IsString(command)) { fprintf(stderr, "protocol error: command is not a string\n"); // FIXME: return an error response - cJSON_free(resp); + cJSON_Delete(resp); return continue_repl; } @@ -549,7 +549,7 @@ static boolean handle_message(char *msg) { boolean continue_repl = true; if (cJSON_IsString(type) && !strcmp(type->valuestring, "request")) continue_repl = handle_request(json); - cJSON_free(json); + cJSON_Delete(json); free(msg); return continue_repl; }