Skip to content
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

Fix a possible crash in avformat probe #944

Merged
merged 2 commits into from
Sep 4, 2023

Conversation

bmatherly
Copy link
Member

Probe was accessing the cached avformat context from a store pointer (self->child) rather than through the cache. This can result in accesssing released memory if the cache deleted the context.

The context pointer should not be saved at all and should only be accessed through the cache system.

This change includes a rewrite of the video index change detection so that probe() will not have to access the avformat context at all.

This also adds an optimization that if metadata is loaded from XML, and nothing else has changed, then the probe can be skipped.

In my testing, this resolves the crash reported here:
https://forum.shotcut.org/t/beta-version-23-09-now-available-to-test/40558/3

Probe was accessing the cached avformat context from a store pointer
(self->child) rather than through the cache. This can result in
accesssing released memory if the cache deleted the context.

The context pointer should not be saved at all and should only be
accessed through the cache system.

This change includes a rewrite of the video index change detection
so that probe() will not have to access the avformat context at all.

This also adds an optimization that if metadata is loaded from XML,
and nothing else has changed, then the probe can be skipped.
@bmatherly bmatherly requested review from ddennedy and j-b-m September 3, 2023 22:33
src/modules/avformat/producer_avformat.c Outdated Show resolved Hide resolved
@ddennedy ddennedy added this to the v7.20.0 milestone Sep 4, 2023
Stream 0 may not exist. And nb_streams should always be present
@ddennedy ddennedy merged commit 2266e5c into mltframework:master Sep 4, 2023
6 checks passed
@bmatherly bmatherly deleted the probe_crash branch November 6, 2023 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants