[PR #2012] [MERGED] fix(rust): Remove dead code returning pointer to stack variable #2813

Open
opened 2026-01-29 17:24:03 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/CCExtractor/ccextractor/pull/2012
Author: @cfsmp3
Created: 1/10/2026
Status: Merged
Merged: 1/18/2026
Merged by: @cfsmp3

Base: masterHead: fix/remove-dead-pmtentry-pointer-impl


📝 Commits (1)

  • aac90d5 fix(rust): Remove dead code returning pointer to stack variable

📊 Changes

1 file changed (+0 additions, -44 deletions)

View changed files

📝 src/rust/src/ctorust.rs (+0 -44)

📄 Description

Summary

Removes unused impl FromCType<*mut PMT_entry> for *mut PMTEntry which contained a critical bug: returning a pointer to a stack-allocated value (undefined behavior).

Problem

The deleted code did this:

let mut pmt_entry = PMTEntry { ... };
Some(&mut pmt_entry as *mut PMTEntry)  // BUG: dangling pointer!

When the function returns, pmt_entry is destroyed and the pointer becomes dangling.

Why delete instead of fix?

This code was never called anywhere in the codebase:

  • The actual usage in demuxer.rs:279 uses the value-returning variant: PMTEntry::from_ctype(*buffer_ptr)
  • That call site already wraps it properly: Box::into_raw(Box::new(PMTEntry::from_ctype(...)?))

Rather than fix dead buggy code (and introduce memory ownership complexity), just delete it.

Verification

  • Build passes ✓
  • All 265 Rust tests pass ✓
  • No code references this implementation

Supersedes #1988 which attempted to fix this bug rather than delete the dead code.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/CCExtractor/ccextractor/pull/2012 **Author:** [@cfsmp3](https://github.com/cfsmp3) **Created:** 1/10/2026 **Status:** ✅ Merged **Merged:** 1/18/2026 **Merged by:** [@cfsmp3](https://github.com/cfsmp3) **Base:** `master` ← **Head:** `fix/remove-dead-pmtentry-pointer-impl` --- ### 📝 Commits (1) - [`aac90d5`](https://github.com/CCExtractor/ccextractor/commit/aac90d5a5f44afe4225307bfaf380e7e4b4daad9) fix(rust): Remove dead code returning pointer to stack variable ### 📊 Changes **1 file changed** (+0 additions, -44 deletions) <details> <summary>View changed files</summary> 📝 `src/rust/src/ctorust.rs` (+0 -44) </details> ### 📄 Description ## Summary Removes unused `impl FromCType<*mut PMT_entry> for *mut PMTEntry` which contained a critical bug: returning a pointer to a stack-allocated value (undefined behavior). ## Problem The deleted code did this: ```rust let mut pmt_entry = PMTEntry { ... }; Some(&mut pmt_entry as *mut PMTEntry) // BUG: dangling pointer! ``` When the function returns, `pmt_entry` is destroyed and the pointer becomes dangling. ## Why delete instead of fix? This code was **never called anywhere** in the codebase: - The actual usage in `demuxer.rs:279` uses the **value-returning** variant: `PMTEntry::from_ctype(*buffer_ptr)` - That call site already wraps it properly: `Box::into_raw(Box::new(PMTEntry::from_ctype(...)?))` Rather than fix dead buggy code (and introduce memory ownership complexity), just delete it. ## Verification - Build passes ✓ - All 265 Rust tests pass ✓ - No code references this implementation ## Related Supersedes #1988 which attempted to fix this bug rather than delete the dead code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 17:24:03 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2813