From d91d87690523ec9d345358eca963c05095b53824 Mon Sep 17 00:00:00 2001 From: dmiller Date: Tue, 15 Jul 2025 18:22:27 +0000 Subject: [PATCH] Avoid dereferencing freed pointer --- nse_libssh2.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nse_libssh2.cc b/nse_libssh2.cc index 1be5d2944..0660937bb 100644 --- a/nse_libssh2.cc +++ b/nse_libssh2.cc @@ -850,6 +850,7 @@ struct request_context { static int channel_request (lua_State *L, int status, lua_KContext ctx) { int rc; request_context *req_ctx = (request_context *)ctx; + const char* request_str = req_ctx->request; DO_OR_YIELD((rc = libssh2_channel_process_startup(req_ctx->channel, req_ctx->request, req_ctx->request_len, @@ -859,7 +860,7 @@ static int channel_request (lua_State *L, int status, lua_KContext ctx) { free(req_ctx); if (rc != 0) - return luaL_error(L, "Error sending %s request", req_ctx->request); + return luaL_error(L, "Error sending %s request", request_str); return 0; }