From 15fb78f0423a99f1464e08f3a5b6bbcfa1591de7 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 11 Mar 2009 02:15:33 +0000 Subject: [PATCH] Fix a small memory leak in thread_record::get_id. --- nse_main.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nse_main.cc b/nse_main.cc index 01e21566e..d147a9f45 100644 --- a/nse_main.cc +++ b/nse_main.cc @@ -42,6 +42,7 @@ struct thread_record { /* Gets the basename of a script filename and removes any ".nse" extension. */ std::string thread_record::get_id() const { char *abbrev; + std::string result; abbrev = path_get_basename(filename.c_str()); if (abbrev == NULL) @@ -49,8 +50,10 @@ std::string thread_record::get_id() const { return filename; if (nse_check_extension(SCRIPT_ENGINE_EXTENSION, abbrev)) abbrev[strlen(abbrev) - strlen(SCRIPT_ENGINE_EXTENSION)] = '\0'; + result = abbrev; + free(abbrev); - return std::string(abbrev); + return result; } int current_hosts = 0;