summaryrefslogtreecommitdiff
path: root/lsp-parse.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-01-03 23:35:02 -0500
committerpommicket <pommicket@gmail.com>2023-01-03 23:35:02 -0500
commit4e73c6a204383667aad6ce3905e16aee2a172fb6 (patch)
tree1e075fa743ea6277679404f7bfd3caecaa1f4308 /lsp-parse.c
parentb6460a7aac5196b8cb6174bdaa8cc2ab82310380 (diff)
fix double-free response_to
also cancel old workspace/symbols requests
Diffstat (limited to 'lsp-parse.c')
-rw-r--r--lsp-parse.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lsp-parse.c b/lsp-parse.c
index 42f2291..4c3e95f 100644
--- a/lsp-parse.c
+++ b/lsp-parse.c
@@ -879,6 +879,9 @@ void process_message(LSP *lsp, JSON *json) {
LSPResponse response = {0};
bool add_to_messages = false;
response.request = response_to;
+ // now response_to is response's responsibility
+ memset(&response_to, 0, sizeof response_to);
+
// make sure (LSPString){0} gets treated as an empty string
arr_add(response.string_data, '\0');
@@ -889,7 +892,7 @@ void process_message(LSP *lsp, JSON *json) {
if (response.error) {
if (error_code != LSP_ERROR_REQUEST_CANCELLED)
add_to_messages = true;
- } else switch (response_to.type) {
+ } else switch (response.request.type) {
case LSP_REQUEST_COMPLETION:
add_to_messages = parse_completion(lsp, json, &response);
break;
@@ -952,7 +955,6 @@ void process_message(LSP *lsp, JSON *json) {
message->type = LSP_RESPONSE;
message->u.response = response;
SDL_UnlockMutex(lsp->messages_mutex);
- memset(&response_to, 0, sizeof response_to); // don't free
} else {
lsp_response_free(&response);
}