File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ class TBinaryJsonEntryTest : public TBinaryJsonTestBase {
17
17
UNIT_TEST (TestGetContainer);
18
18
UNIT_TEST (TestGetString);
19
19
UNIT_TEST (TestGetNumber);
20
+ UNIT_TEST (TestInvalidInput);
20
21
UNIT_TEST_SUITE_END ();
21
22
22
23
void TestGetType () {
@@ -93,6 +94,18 @@ class TBinaryJsonEntryTest : public TBinaryJsonTestBase {
93
94
UNIT_ASSERT_VALUES_EQUAL (container.GetElement (0 ).GetNumber (), testCase.second );
94
95
}
95
96
}
97
+
98
+ void TestInvalidInput () {
99
+ const TVector<std::pair<TString, TString>> testCases = {
100
+ {" nul" , " N_ATOM_ERROR: Problem while parsing an atom starting with the letter 'n'" },
101
+ };
102
+
103
+ for (const auto & testCase : testCases) {
104
+ const auto parsingResult = SerializeToBinaryJson (testCase.first );
105
+ UNIT_ASSERT (parsingResult.IsFail ());
106
+ UNIT_ASSERT_VALUES_EQUAL (parsingResult.GetErrorMessage (), testCase.second );
107
+ }
108
+ }
96
109
};
97
110
98
111
UNIT_TEST_SUITE_REGISTRATION (TBinaryJsonEntryTest);
Original file line number Diff line number Diff line change @@ -600,7 +600,9 @@ template <typename TOnDemandValue>
600
600
case simdjson::ondemand::json_type::null: {
601
601
auto is_null = value.is_null ();
602
602
RETURN_IF_NOT_SUCCESS (is_null.error ());
603
- Y_ABORT_UNLESS (is_null.value_unsafe ());
603
+ if (Y_UNLIKELY (!is_null.value_unsafe ())) {
604
+ return simdjson::error_code::N_ATOM_ERROR;
605
+ }
604
606
callbacks.OnNull ();
605
607
break ;
606
608
}
You can’t perform that action at this time.
0 commit comments