aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2020-09-10 09:11:46 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2020-09-10 09:11:46 -0700
commit20aef1cd4b436a8859a54b41cc992db517c61d2d (patch)
tree5725aa4668fd7dd23a7eca691453c7af285e70fb
parentc7090e6c3329a4d30f69919186276ac237726368 (diff)
downloadpugixml-20aef1cd4b436a8859a54b41cc992db517c61d2d.zip
pugixml-20aef1cd4b436a8859a54b41cc992db517c61d2d.tar.gz
pugixml-20aef1cd4b436a8859a54b41cc992db517c61d2d.tar.bz2
Fix stack overflow in tests on MSVC x64
The default stack on MSVC/x64/debug is sufficient for 1692 nested invocations only, whereas on clang/linux it's ~8K... For now set the limit to be conservative.
-rw-r--r--src/pugiconfig.hpp3
-rw-r--r--src/pugixml.cpp2
-rw-r--r--tests/test_xpath_parse.cpp2
3 files changed, 5 insertions, 2 deletions
diff --git a/src/pugiconfig.hpp b/src/pugiconfig.hpp
index 2fb6918..c9c40e2 100644
--- a/src/pugiconfig.hpp
+++ b/src/pugiconfig.hpp
@@ -40,6 +40,9 @@
// #define PUGIXML_MEMORY_OUTPUT_STACK 10240
// #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096
+// Tune this constant to adjust max nesting for XPath queries
+// #define PUGIXML_XPATH_DEPTH_LIMIT 1024
+
// Uncomment this to switch to header-only version
// #define PUGIXML_HEADER_ONLY
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 34e126f..e166458 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -11147,7 +11147,7 @@ PUGI__NS_BEGIN
#ifdef PUGIXML_XPATH_DEPTH_LIMIT
PUGIXML_XPATH_DEPTH_LIMIT
#else
- 4096
+ 1024
#endif
;
diff --git a/tests/test_xpath_parse.cpp b/tests/test_xpath_parse.cpp
index 89c66a3..d0b0bac 100644
--- a/tests/test_xpath_parse.cpp
+++ b/tests/test_xpath_parse.cpp
@@ -394,7 +394,7 @@ static std::basic_string<char_t> rep(const std::basic_string<char_t>& base, size
TEST(xpath_parse_depth_limit)
{
- const size_t limit = 5000;
+ const size_t limit = 1500;
CHECK_XPATH_FAIL((rep(STR("("), limit) + STR("1") + rep(STR(")"), limit)).c_str());
CHECK_XPATH_FAIL((STR("(id('a'))") + rep(STR("[1]"), limit)).c_str());