Skip to content

Commit 7a91282

Browse files
0hmXaduh95
authored andcommitted
src: use simdjson::pad
PR-URL: #59391 Refs: #59389 Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 2237142 commit 7a91282

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

src/node_modules.cc

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,11 @@ const BindingData::PackageConfig* BindingData::GetPackageJSON(
102102
if (ReadFileSync(&package_config.raw_json, path.data()) < 0) {
103103
return nullptr;
104104
}
105-
// In some systems, std::string is annotated to generate an
106-
// AddressSanitizer: container-overflow error when reading beyond the end of
107-
// the string even when we are still within the capacity of the string.
108-
// https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow
109-
// https://github.com/nodejs/node/issues/55584
110-
// The next lines are a workaround to avoid this false positive.
111-
size_t json_length = package_config.raw_json.size();
112-
package_config.raw_json.append(simdjson::SIMDJSON_PADDING, ' ');
113-
simdjson::padded_string_view json_view(package_config.raw_json.data(),
114-
json_length,
115-
package_config.raw_json.size());
116-
// End of workaround
117-
118105
simdjson::ondemand::document document;
119106
simdjson::ondemand::object main_object;
120107
simdjson::error_code error =
121-
binding_data->json_parser.iterate(json_view).get(document);
108+
binding_data->json_parser.iterate(simdjson::pad(package_config.raw_json))
109+
.get(document);
122110

123111
const auto throw_invalid_package_config = [error_context, path, realm]() {
124112
if (error_context == nullptr) {

0 commit comments

Comments
 (0)