Skip to content

merge_pr_49828

Compare
Choose a tag to compare
@github-actions github-actions released this 24 Dec 21:45

VideoEncoder: Return unsupported for codec strings with spaces

This patch fixes a crash that occurs when a codec string with leading
spaces is passed to VideoEncoder::IsConfigSupported.

The crash happens because VideoEncoderConfigInternal::ToEncoderConfig
assumes that its codec string member begins with a supported codec name
(which should be non-space character). When the codec string has leading
spaces, this assumption is invalidated, leading to a crash.

To resolve this issue, the patch removes the space-trimming in
CanEncode and calling IsSupportedVideoCodec with the given codec
string directly before ToEncoderConfig. By doing so, codec strings
with leading spaces are correctly identified as "unsupported", and
ToEncoderConfig is not invoked with invalid input, preventing the
crash.

Additionally, this patch adds a WPT to ensure that codec string
containing spaces are reported as "unsupported" and the no crash occurs
when such strings are processed.

Differential Revision: https://phabricator.services.mozilla.com/D231719

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1936352
gecko-commit: 00a6b47b218e193d0018ffbd2996e0112d2a90f3
gecko-reviewers: media-playback-reviewers, alwu