Skip to content

media-playback: Fix possible crash if frame width or height is zero#12024

Merged
RytoEX merged 1 commit intoobsproject:masterfrom
RytoEX:fix-media-playback-zero-width-height
Apr 23, 2025
Merged

media-playback: Fix possible crash if frame width or height is zero#12024
RytoEX merged 1 commit intoobsproject:masterfrom
RytoEX:fix-media-playback-zero-width-height

Conversation

@RytoEX
Copy link
Member

@RytoEX RytoEX commented Apr 1, 2025

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

https://obsproject.com/logs/3ApOqPpoBR2XcHqO
2025-03-30 23-01-46-1.txt

See also:

How Has This Been Tested?

Tested locally by forcing width or height to zero to see if OBS crashes or not.

I have not been able to spontaneously reproduce this crash otherwise.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

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.
@RytoEX RytoEX added the Bug Fix Non-breaking change which fixes an issue label Apr 1, 2025
@RytoEX RytoEX requested review from Lain-B, notr1ch and tt2468 April 1, 2025 19:23
@RytoEX RytoEX self-assigned this Apr 1, 2025
@RytoEX RytoEX added this to the OBS Studio 31.1 milestone Apr 23, 2025
@RytoEX RytoEX merged commit 7cae57d into obsproject:master Apr 23, 2025
15 checks passed
@RytoEX RytoEX deleted the fix-media-playback-zero-width-height branch April 29, 2025 00:17
@RytoEX RytoEX mentioned this pull request Jun 27, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Fix Non-breaking change which fixes an issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant