From c412ace49d876392cf7c36167cc6b2b6504af5a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=BCchler?= Date: Wed, 6 Jul 2016 15:19:06 +0200 Subject: [PATCH 1/3] Allow to query non-existant sections Sometimes it is convenient to query a library for a specific section and expect an empty result if the section does not exists. This was not possible because library_info ASSERTed the section adresses thus crashing the Application if a section was not found. Fixed this by checking section begin and end and returning an emtpy vector of string if the section was not found. --- include/boost/dll/detail/pe_info.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/boost/dll/detail/pe_info.hpp b/include/boost/dll/detail/pe_info.hpp index 7f1584a..341a123 100644 --- a/include/boost/dll/detail/pe_info.hpp +++ b/include/boost/dll/detail/pe_info.hpp @@ -320,8 +320,10 @@ class pe_info: public x_info_interface { section_end_addr = section_begin_addr + image_section_header.SizeOfRawData; } } - BOOST_ASSERT(section_begin_addr); - BOOST_ASSERT(section_end_addr); + + // returning empty result if section was not found + if(section_begin_addr == 0 || section_end_addr == 0) + return ret; } const exports_t exprt = exports(h); From b044c41e099503bdfffef7baa3f728b39e3da8d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=BCchler?= Date: Thu, 7 Jul 2016 08:25:14 +0200 Subject: [PATCH 2/3] Add test to query empty section Adds test which ensures empty vector is returned if an empty section is queried. --- test/library_info_test.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/library_info_test.cpp b/test/library_info_test.cpp index bce2581..916432a 100644 --- a/test/library_info_test.cpp +++ b/test/library_info_test.cpp @@ -44,6 +44,8 @@ int main(int argc, char* argv[]) BOOST_TEST(std::find(symb.begin(), symb.end(), "say_hello") == symb.end()); BOOST_TEST(lib_info.symbols(std::string("boostdll")) == symb); + empty = lib_info.symbols("empty"); + BOOST_TEST(empty.empty() == true); // Self testing std::cout << "Self: " << argv[0]; From f3fd8076cee77954c655f78ad4837ec9156d61cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=BCchler?= Date: Thu, 7 Jul 2016 09:03:59 +0200 Subject: [PATCH 3/3] Add type --- test/library_info_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/library_info_test.cpp b/test/library_info_test.cpp index 916432a..113f6ee 100644 --- a/test/library_info_test.cpp +++ b/test/library_info_test.cpp @@ -44,7 +44,7 @@ int main(int argc, char* argv[]) BOOST_TEST(std::find(symb.begin(), symb.end(), "say_hello") == symb.end()); BOOST_TEST(lib_info.symbols(std::string("boostdll")) == symb); - empty = lib_info.symbols("empty"); + std::vector empty = lib_info.symbols("empty"); BOOST_TEST(empty.empty() == true); // Self testing