Avoid creating unsound slice reference

fix(serde_v8): avoid creating unsound slice reference (#16189)
Avoid creating unsound slice referencefixavoid creating unsound slice reference serde

Committed by Nugine

commit message
fix(serde_v8): avoid creating unsound slice reference (#16189)

This commit fixes one ocurrence of unsoundness by using the newly added
API (`v8::String::write_utf8_uninit`).
 
See also
[`clippy:uninit_vec`](https://rust-lang.github.io/rust-clippy/master/index.html#uninit_vec).
 
Note that it is not actually a bug. Avoiding unsoundness improves our
code quality.

Editor assessment

This is a model fix write-up. The subject states the hazard precisely, avoiding an unsound slice reference, and the body explains the mechanism, the new v8::String::write_utf8_uninit API, links the relevant clippy lint, and honestly qualifies that it was not an active bug but a soundness improvement. That nuance is valuable. Wrapping is clean at roughly 70 columns, and the blank line between header and body is correct. One could argue refactor is the truer type given no behavior change, but flagging unsoundness as fix is a defensible safety-first convention.

Browse categories

More fix examples · Back to search