libobs/media-io: Avoid allocating frame memory if size is zero#11803
libobs/media-io: Avoid allocating frame memory if size is zero#11803RytoEX wants to merge 1 commit intoobsproject:masterfrom
Conversation
It is possible that size can still be zero after the preceding loop. If that happens, and bmalloc is called with 0 as its argument, OBS will crash as intended with OBS Studio 31. Avoid crashing by not allocating memory for a frame with a size of zero.
|
I think my primary worry here would be that video_frame_init is a void return, so we might not actually be fixing any issues, rather pushing the undefined behavior to somewhere else. |
obs-studio/libobs/media-io/video-frame.c Lines 198 to 199 in 0b2c858 That said, I'm open to alternatives, but we intentionally crash if |
|
We could add |
The crash that motivated this PR is mentioned in #11729. Some issue with a Video Capture Device source on Windows caused OBS to crash when |
Description
It is possible that size can still be zero after the preceding loop. If that happens, and bmalloc is called with 0 as its argument, OBS will crash as intended with OBS Studio 31. Avoid crashing by not allocating memory for a frame with a size of zero.
Motivation and Context
See the crash in:
If there's a better place to do this check, I'm open to alternatives.
How Has This Been Tested?
Compiled and ran locally on Windows 11 with a Video Capture Device added.
Types of changes
Checklist: