What changed, and why it matters
This commit moves a memory-freeing operation from one cryptocurrency display structure (Ethereum Swapkit) to another (Tron). It appears to fix a code review finding about a string pointer being freed in the wrong place, which could otherwise lead to a use-after-free or double-free memory bug. The actual security impact depends on whether the affected field is heap-allocated and how the structures are used after freeing.
Review the struct definitions to confirm pointer ownership for `raw_value`, ensure all heap-allocated string fields are freed exactly once, and run static/dynamic analysis on the FFI boundary. Consider adding tests or assertions to prevent similar ownership mismatches.
Security signals we found
Memory management change in FFI Rust/C boundary
Relocation of `free_str_ptr!` call between structs
Potential double-free or use-after-free if pointer ownership was mismatched
Potential memory leak if `raw_value` was previously not freed for Tron
Evidence from the diff
The diff removes free_str_ptr!(self.raw_value) from DisplaySwapkitContractData::free() in ethereum/structs.rs and adds the same line to DisplayTronDetail::free() in tron/structs.rs. This suggests raw_value belongs to the Tron detail struct but was incorrectly freed in the Ethereum Swapkit implementation, or the field was moved between structs. In Rust/C FFI code, freeing a pointer that does not belong to the current struct can cause double-free or use-after-free if the memory is later accessed. Conversely, failing to free an owned heap pointer causes a memory leak. The patch is a one-line relocation with no broader context, so the exact vulnerability and exploitability are uncertain.
Changed components
rust/rust_c/src/ethereum/structs.rsrust/rust_c/src/tron/structs.rsDisplaySwapkitContractDataDisplayTronDetailInspect captured patch +1 / −1
diff --git a/rust/rust_c/src/ethereum/structs.rs b/rust/rust_c/src/ethereum/structs.rs
index 2f60343..aa63bf4 100644
--- a/rust/rust_c/src/ethereum/structs.rs
+++ b/rust/rust_c/src/ethereum/structs.rs
@@ -538,7 +538,6 @@ impl Free for DisplaySwapkitContractData {
free_str_ptr!(self.swap_out_asset);
free_str_ptr!(self.receive_address);
free_str_ptr!(self.expiration);
- free_str_ptr!(self.raw_value);
}
}
diff --git a/rust/rust_c/src/tron/structs.rs b/rust/rust_c/src/tron/structs.rs
index a40be80..fa39ccd 100644
--- a/rust/rust_c/src/tron/structs.rs
+++ b/rust/rust_c/src/tron/structs.rs
@@ -101,6 +101,7 @@ impl Free for DisplayTronDetail {
free_str_ptr!(self.contract_address);
free_str_ptr!(self.memo);
free_str_ptr!(self.expiration);
+ free_str_ptr!(self.raw_value);
}
}
Why this scored 37/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.