From aac90d5a5f44afe4225307bfaf380e7e4b4daad9 Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Sat, 10 Jan 2026 23:41:32 +0100 Subject: [PATCH] fix(rust): Remove dead code returning pointer to stack variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Delete the unused `impl FromCType<*mut PMT_entry> for *mut PMTEntry` implementation which had a critical bug: it returned a pointer to a stack-allocated PMTEntry, causing undefined behavior (dangling pointer). This code was never called anywhere in the codebase. The actual usage in demuxer.rs uses the value-returning variant `FromCType for PMTEntry` with explicit `Box::into_raw(Box::new(...))` wrapping, which is the correct pattern. Rather than fixing dead buggy code, just remove it. Supersedes #1988 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/rust/src/ctorust.rs | 44 ----------------------------------------- 1 file changed, 44 deletions(-) diff --git a/src/rust/src/ctorust.rs b/src/rust/src/ctorust.rs index 5ab729fe3..f240c5020 100755 --- a/src/rust/src/ctorust.rs +++ b/src/rust/src/ctorust.rs @@ -615,50 +615,6 @@ impl FromCType for CcxDemuxReport { } } -/// # Safety -/// This function is unsafe because it takes a raw pointer to a C struct. -impl FromCType<*mut PMT_entry> for *mut PMTEntry { - unsafe fn from_ctype(buffer_ptr: *mut PMT_entry) -> Option { - if buffer_ptr.is_null() { - return None; - } - - let buffer = unsafe { &*buffer_ptr }; - - let program_number = if buffer.program_number != 0 { - buffer.program_number - } else { - 0 - }; - - let elementary_pid = if buffer.elementary_PID != 0 { - buffer.elementary_PID - } else { - 0 - }; - - let stream_type = if buffer.stream_type != 0 { - StreamType::from_ctype(buffer.stream_type as u32).unwrap_or(StreamType::Unknownstream) - } else { - StreamType::Unknownstream - }; - - let printable_stream_type = if buffer.printable_stream_type != 0 { - buffer.printable_stream_type - } else { - 0 - }; - - let mut pmt_entry = PMTEntry { - program_number, - elementary_pid, - stream_type, - printable_stream_type, - }; - - Some(&mut pmt_entry as *mut PMTEntry) - } -} impl FromCType for BufferdataType { unsafe fn from_ctype(c_value: ccx_bufferdata_type) -> Option { let rust_value = match c_value {