From 084c2086a4839987668564325c0cada5bf0fa2c7 Mon Sep 17 00:00:00 2001 From: Robin Sommer Date: Thu, 7 Jul 2011 11:06:42 -0700 Subject: [PATCH] Fixing bug causing crash when running without arguments. --- src/scan.l | 6 ++++-- testing/btest/Baseline/core.nop/output | 0 testing/btest/core/nop.bro | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 testing/btest/Baseline/core.nop/output create mode 100644 testing/btest/core/nop.bro diff --git a/src/scan.l b/src/scan.l index 8f5fcee1d8..249a55ef0d 100644 --- a/src/scan.l +++ b/src/scan.l @@ -527,6 +527,7 @@ static int load_files_with_prefix(const char* orig_file) const char* full_filename = ""; const char* bropath_subpath = ""; + const char* bropath_subpath_delete = 0; FILE* f; if ( streq(orig_file, "-") ) @@ -552,6 +553,7 @@ static int load_files_with_prefix(const char* orig_file) strcpy(new_filename, orig_file); f = search_for_file(new_filename, "bro", &full_filename, true, &bropath_subpath); + bropath_subpath_delete = bropath_subpath; // This will be deleted. delete [] new_filename; } @@ -566,7 +568,7 @@ static int load_files_with_prefix(const char* orig_file) { fclose(f); delete [] full_filename; - delete [] bropath_subpath; + delete [] bropath_subpath_delete; return 0; } } @@ -617,7 +619,7 @@ static int load_files_with_prefix(const char* orig_file) docs_generated.push_back(current_reST_doc); } - delete [] bropath_subpath; + delete [] bropath_subpath_delete; // "orig_file", could be an alias for yytext, which is ephemeral // and will be zapped after the yy_switch_to_buffer() below. diff --git a/testing/btest/Baseline/core.nop/output b/testing/btest/Baseline/core.nop/output new file mode 100644 index 0000000000..e69de29bb2 diff --git a/testing/btest/core/nop.bro b/testing/btest/core/nop.bro new file mode 100644 index 0000000000..e42b5a7821 --- /dev/null +++ b/testing/btest/core/nop.bro @@ -0,0 +1,4 @@ +# Bro shouldn't crash when doing nothing, nor outputting anything. +# +# @TEST-EXEC: cat /dev/null | bro >output 2>&1 +# @TEST-EXEC: btest-diff output