[FIX]Fix panic when using --mp4/--mkv without explicit input format#2107
[FIX]Fix panic when using --mp4/--mkv without explicit input format#2107gaurav02081 wants to merge 5 commits intoCCExtractor:masterfrom
Conversation
|
Previously: set_input_format() was called conditionally through a guard in parse_parameters(), meaning it was skipped during most normal (autodetection) runs. Additionally, the fatal! fallback inside set_input_format() would terminate execution if no explicit format matched, preventing autodetection from taking place. This caused unintended behavior: Normal runs could bypass initialization logic. If triggered without a matching format, the function would exit instead of allowing autodetection. Final Fix Removed the fatal! fallback so that when no explicit format flag matches, the function simply returns and preserves autodetection behavior. Removed the guard in parse_parameters() so that set_input_format() is always called as part of initialization. Explicit handling for --mp4 and --mkv remains intact. The unsafe unwrap() has been eliminated. |
cfsmp3
left a comment
There was a problem hiding this comment.
Review
The bug is real — confirmed that --mp4 (and --mkv) cause an abort on master because set_input_format() doesn't handle these flags, falls through to the fatal! macro, and args.input.unwrap() panics on None.
However, the fix is over-engineered. You're commenting out the fatal! and commenting out the guard condition, when the actual fix is just 2 lines.
What's wrong with the current approach:
- Commenting out code instead of removing it — commented-out code is dead code. Either remove it or keep it.
- Removing the guard condition — the guard at line 661-672 correctly prevents calling
set_input_format()when no format flags are set. Removing it is unnecessary. - Removing the fatal — the
fatal!for unknown formats is a useful error message. It should stay, just with theunwrap()fixed.
The correct fix (3 lines changed):
In set_input_format(), add the missing handlers before the else branch:
} else if args.wtv {
self.set_input_format_type(InFormat::Wtv);
+ } else if args.mp4 {
+ self.set_input_format_type(InFormat::Mp4);
+ } else if args.mkv {
+ self.set_input_format_type(InFormat::Mkv);
} else {
fatal!(
cause = ExitCause::MalformedParameter;
- "Unknown input file format: {}\n", args.input.unwrap()
+ "Unknown input file format: {}\n", args.input.unwrap_or("unknown")
);
}That's it. Keep the guard condition as-is (it already includes args.mp4 and args.mkv). Keep the fatal! for genuinely unknown formats. Just add the missing handlers and fix the unwrap().
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
Properly handle mp4/mkv flags in set_input_format() and replace args.input.unwrap() with unwrap_or().
1f81c73 to
f1368b5
Compare
|
@cfsmp3 Thanks for the review I have applied the suggested changes and kept the original guard and fatal! logic intact. While implementing -
To keep the behavior the same while ensuring type safety, I updated the fatal! call to: This preserves the intended error message while avoiding the panic . |
CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit 0626bb5...:
Your PR breaks these cases:
Congratulations: Merging this PR would fix the following tests:
It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you). Check the result page for more info. |
CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results, when compared to test for commit 0626bb5...:
Your PR breaks these cases:
Congratulations: Merging this PR would fix the following tests:
It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you). Check the result page for more info. |
[FIX]Fix panic when using --mp4/--mkv without explicit input format
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Found a issue --
if the user use --mp4 ya --mkv with invalid / broken file ,then the programs gets crashes instead of handling that with error message .
it is happeing because of the unwrap() METHOD
command used for reproduce the issue
FIX -- (src/rust/src/parser.rs)
and added flags rgs.mp4 and args.mkv in the set_input_format function
replace unwrap with map with closures.
After the fix, the program no longer crashes