Skip to content

Commit 3462b46

Browse files
0hmXtargos
authored andcommitted
src: use simdjson::pad
PR-URL: #59391 Refs: #59389 Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 0930c21 commit 3462b46

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
@@ -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);
127115

128116
const auto throw_invalid_package_config = [error_context, path, realm]() {
129117
if (error_context == nullptr) {

0 commit comments

Comments
 (0)