mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
src: use simdjson::pad
PR-URL: https://github.com/nodejs/node/pull/59391 Refs: https://github.com/nodejs/node/issues/59389 Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
@@ -107,23 +107,11 @@ const BindingData::PackageConfig* BindingData::GetPackageJSON(
|
||||
if (ReadFileSync(&package_config.raw_json, path.data()) < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
// In some systems, std::string is annotated to generate an
|
||||
// AddressSanitizer: container-overflow error when reading beyond the end of
|
||||
// the string even when we are still within the capacity of the string.
|
||||
// https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow
|
||||
// https://github.com/nodejs/node/issues/55584
|
||||
// The next lines are a workaround to avoid this false positive.
|
||||
size_t json_length = package_config.raw_json.size();
|
||||
package_config.raw_json.append(simdjson::SIMDJSON_PADDING, ' ');
|
||||
simdjson::padded_string_view json_view(package_config.raw_json.data(),
|
||||
json_length,
|
||||
package_config.raw_json.size());
|
||||
// End of workaround
|
||||
|
||||
simdjson::ondemand::document document;
|
||||
simdjson::ondemand::object main_object;
|
||||
simdjson::error_code error =
|
||||
binding_data->json_parser.iterate(json_view).get(document);
|
||||
binding_data->json_parser.iterate(simdjson::pad(package_config.raw_json))
|
||||
.get(document);
|
||||
|
||||
const auto throw_invalid_package_config = [error_context, path, realm]() {
|
||||
if (error_context == nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user