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 {
1717 UNIT_TEST (TestGetContainer);
1818 UNIT_TEST (TestGetString);
1919 UNIT_TEST (TestGetNumber);
20+ UNIT_TEST (TestInvalidInput);
2021 UNIT_TEST_SUITE_END ();
2122
2223 void TestGetType () {
@@ -93,6 +94,18 @@ class TBinaryJsonEntryTest : public TBinaryJsonTestBase {
9394 UNIT_ASSERT_VALUES_EQUAL (container.GetElement (0 ).GetNumber (), testCase.second );
9495 }
9596 }
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+ }
96109};
97110
98111UNIT_TEST_SUITE_REGISTRATION (TBinaryJsonEntryTest);
Original file line number Diff line number Diff line change @@ -600,7 +600,9 @@ template <typename TOnDemandValue>
600600 case simdjson::ondemand::json_type::null: {
601601 auto is_null = value.is_null ();
602602 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+ }
604606 callbacks.OnNull ();
605607 break ;
606608 }
You can’t perform that action at this time.
0 commit comments