Skip to content

Commit

Permalink
Cherry-pick f790c5f. rdar://115055098
Browse files Browse the repository at this point in the history
    REGRESSION(267279@main): media/media-source/media-source-seek-detach-crash.html causes a crash
    https://bugs.webkit.org/show_bug.cgi?id=261202
    rdar://115055098

    Reviewed by Youenn Fablet.

    Call completionHandler immediately when MediaSource is closed.

    * Source/WebCore/Modules/mediasource/MediaSource.cpp:
    (WebCore::MediaSource::seekToTarget):
    (WebCore::MediaSource::completeSeek): Fly-by fix, exit loop early when an error has occurred.

    Canonical link: https://commits.webkit.org/267675@main

Canonical link: https://commits.webkit.org/265870.561@safari-7616-branch
  • Loading branch information
jyavenard authored and drobson1005 committed Sep 19, 2023
1 parent 0a6ca7f commit e5883e4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Source/WebCore/Modules/mediasource/MediaSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,10 @@ const PlatformTimeRanges& MediaSource::buffered() const

void MediaSource::seekToTarget(const SeekTarget& target, CompletionHandler<void(const MediaTime&)>&& completionHandler)
{
if (isClosed())
if (isClosed()) {
completionHandler(MediaTime::invalidTime());
return;
}

ALWAYS_LOG(LOGIDENTIFIER, target.time);

Expand Down Expand Up @@ -256,8 +258,10 @@ void MediaSource::completeSeek()
{
auto seekTime = time;
for (auto& result : seekResults) {
if (result.isInvalid())
if (result.isInvalid()) {
completionHandler(MediaTime::invalidTime());
return;
}
if (abs(time - result) > abs(time - seekTime))
seekTime = result;
}
Expand Down

0 comments on commit e5883e4

Please sign in to comment.