diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2024-04-14 15:48:05 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2024-04-14 22:18:33 -0400 |
| commit | bf3deccdadffbd5903268cca74a60f7101f7e9c3 (patch) | |
| tree | fb1a5e1636827f9f40e9730061ab3bce439f1c17 /compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp | |
| parent | a8a88fe5243cbeb37d8a9de8c5ca63136c0604b0 (diff) | |
| download | rust-bf3deccdadffbd5903268cca74a60f7101f7e9c3.tar.gz rust-bf3deccdadffbd5903268cca74a60f7101f7e9c3.zip | |
Fix UB in LLVM FFI when passing zero or >1 bundle
Rust passes a *const &OperandBundleDef to these APIs, usually from a Vec<&OperandBundleDef> or so. Previously we were dereferencing that pointer and passing it to the ArrayRef constructor with some length (N). This meant that if the length was 0, we were dereferencing a pointer to nowhere, and if the length was >1 then loading the *second* element somewhere in LLVM would've been reading past the end. Since Rust can't hold OperandBundleDef by-value we're forced to indirect through a vector that copies out the OperandBundleDefs from the by-reference list on the Rust side in order to match the LLVM expected API.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
