src: use simdjson::pad · nodejs/node@3462b46

@@ -107,23 +107,11 @@ const BindingData::PackageConfig* BindingData::GetPackageJSON(

107107

if (ReadFileSync(&package_config.raw_json, path.data()) < 0) {

108108

return nullptr;

109109

}

110-

// In some systems, std::string is annotated to generate an

111-

// AddressSanitizer: container-overflow error when reading beyond the end of

112-

// the string even when we are still within the capacity of the string.

113-

// https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow

114-

// https://github.com/nodejs/node/issues/55584

115-

// The next lines are a workaround to avoid this false positive.

116-

size_t json_length = package_config.raw_json.size();

117-

package_config.raw_json.append(simdjson::SIMDJSON_PADDING, ' ');

118-

simdjson::padded_string_view json_view(package_config.raw_json.data(),

119-

json_length,

120-

package_config.raw_json.size());

121-

// End of workaround

122-123110

simdjson::ondemand::document document;

124111

simdjson::ondemand::object main_object;

125112

simdjson::error_code error =

126-

binding_data->json_parser.iterate(json_view).get(document);

113+

binding_data->json_parser.iterate(simdjson::pad(package_config.raw_json))

114+

.get(document);

127115128116

const auto throw_invalid_package_config = [error_context, path, realm]() {

129117

if (error_context == nullptr) {