From 65e680a6345a8c34cab9fee9d8aa814a22d1ec46 Mon Sep 17 00:00:00 2001 From: fyodor Date: Sat, 11 Aug 2007 04:25:05 +0000 Subject: [PATCH] merge soc07 r4939 - fixed a small bug in formatscriptoutput (output.cc) which caused a core dump --- nse_main.cc | 2 ++ output.cc | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nse_main.cc b/nse_main.cc index 422ff15a8..f2e0db1d8 100644 --- a/nse_main.cc +++ b/nse_main.cc @@ -466,6 +466,8 @@ int process_preparerunlevels(std::list torun_threads) { if(runlevel_idx < (*runlevel_iter).runlevel) { runlevel_idx = (*runlevel_iter).runlevel; current_runlevel.clear(); + //push_back an empty in which we store all scripts of the current + //runlevel... torun_scripts.push_back(current_runlevel); } diff --git a/output.cc b/output.cc index 0c68c0250..3feb27c27 100644 --- a/output.cc +++ b/output.cc @@ -779,8 +779,9 @@ char* formatScriptOutput(struct script_scan_result ssr) { // delete the unwanted trailing newline pos = result.rfind(sep); - result.erase(pos, strlen(sep)); - + if(pos!=std::string::npos){ + result.erase(pos, strlen(sep)); + } c_result = strdup(result.c_str()); return c_result;