-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
win-dshow: Fix possible crash if frame width or height is zero #11861
base: master
Are you sure you want to change the base?
Conversation
If a frame has a width or height of zero, this value will make it into libobs/media-io/video-frame.c:video_frame_init and cause linesizes or heights to be zero, which will result in a bmalloc(0) call and OBS will crash. Instead of letting the call stack get that far, check the frame width and height here at the source, log an error, and return early if the frame width or height are zero.
Wouldn't this imply the numbers in |
Possibly? I was told we should check size for zero in We could try to move this check to We could check around here: obs-studio/plugins/win-dshow/win-dshow.cpp Lines 915 to 924 in 80ea1b1
However, We could check after obs-studio/plugins/win-dshow/win-dshow.cpp Lines 934 to 938 in 80ea1b1
Perhaps this? @@ -942,6 +936,12 @@ bool DShowInput::UpdateVideoConfig(obs_data_t *settings)
return false;
}
+ if (!videoConfig.cx || !videoConfig.cy_abs) {
+ blog(LOG_ERROR, "%s: Frame width or height are zero (%" PRIu32 "x%" PRIu32 ")",
+ obs_source_get_name(source), videoConfig.cx, videoConfig.cy_abs);
+ return false;
+ }
+ This would be after libdshowcapture sets the device config (via Happy to get some guidance here on where a better place to check the frame/config width and height would be. |
It's probably not a huge deal if it's not in the right place and this ends up being a redundant check. If there were specific steps to reproduce that'd be ideal but this is sufficient for now if it's not trivial to reproduce. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if it's not the perfectly right place, if this fixes it for now it's fine -- if there's a better solution we can add that fix in addition later.
Description
If a frame has a width or height of zero, this value will make it into libobs/media-io/video-frame.c:video_frame_init and cause linesizes or heights to be zero, which will result in a bmalloc(0) call and OBS will crash.
Instead of letting the call stack get that far, check the frame width and height here at the source, log an error, and return early if the frame width or height are zero.
Motivation and Context
Alternative to:
Fixes #11729
Fixes #11860
How Has This Been Tested?
Tested locally by forcing
frame.width
orframe.height
above this change to be zero and verifying that the error is logged and OBS does not crash.Types of changes
Checklist: