Skip to content

Commit f03a037

Browse files
committed
Updating JSON parsing depth based on fact that fails on APPLE under debug around 80.
1 parent 6bdf99d commit f03a037

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

Release/src/json/json_parsing.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,16 @@ class JSON_Parser
189189
const typename std::char_traits<CharType>::int_type m_eof;
190190
size_t m_currentColumn;
191191
size_t m_currentParsingDepth;
192+
193+
// On APPLE debug overflow happens around 80.
194+
// The DEBUG macro is defined in XCode but we don't in our CMakeList
195+
// so for now we will keep the same on debug and release. In the future
196+
// this can be increase on release if necessary.
197+
#if defined(__APPLE__)
198+
static const size_t maxParsingDepth = 64;
199+
#else
192200
static const size_t maxParsingDepth = 128;
201+
#endif
193202
};
194203

195204
template <typename CharType>

Release/tests/Functional/json/parsing_tests.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/***
1+
/***
22
* ==++==
33
*
44
* Copyright (c) Microsoft Corporation. All rights reserved.
@@ -490,12 +490,20 @@ utility::string_t make_deep_json_string(size_t depth)
490490

491491
TEST(deeply_nested)
492492
{
493+
#if defined(__APPLE__)
494+
size_t safeDepth = 64;
495+
size_t overDepth = 65;
496+
#else
497+
size_t safeDepth = 128;
498+
size_t overDepth = 129;
499+
#endif
500+
493501
// This should parse without issues:
494-
auto strGood = make_deep_json_string(128);
502+
auto strGood = make_deep_json_string(safeDepth);
495503
json::value::parse(strGood);
496504

497505
// But this one should throw:
498-
auto strBad = make_deep_json_string(129);
506+
auto strBad = make_deep_json_string(overDepth);
499507
VERIFY_PARSING_THROW(json::value::parse(strBad));
500508
}
501509

0 commit comments

Comments
 (0)