From 91bba2e9ffbe75efa819ed2ae3ecfd383219b889 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Mon, 21 Nov 2022 19:48:01 +0100 Subject: [PATCH] fix: free key when adding paste --- src/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index a02da25..8f2d3ad 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -126,13 +126,17 @@ int main() { file.open(std::string("pastes/") + key, std::ios_base::out); if (!file.is_open()) { + free(key); return crow::response(crow::status::INTERNAL_SERVER_ERROR); } file << req.body; file.close(); - return crow::response(base_url + key); + std::string res = base_url + key; + free(key); + + return crow::response(res); }); app.port(18080).multithreaded().run();