win-dshow: Fix possible crash if frame width or height is zero#11861
win-dshow: Fix possible crash if frame width or height is zero#11861RytoEX merged 1 commit intoobsproject:masterfrom
Conversation
|
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. |
Lain-B
left a comment
There was a problem hiding this comment.
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.
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.
e1385c6 to
ca88cdb
Compare
|
Per off-thread discussion, moved the zero checks from |
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
videoConfig.cxorvideoConfig.cy_absabove this change to be zero and verifying that the error is logged and OBS does not crash.Types of changes
Checklist: