Title: [140834] trunk
Revision
140834
Author
[email protected]
Date
2013-01-25 08:58:54 -0800 (Fri, 25 Jan 2013)

Log Message

Heap-use-after-free in WebCore::TextTrackCue::isActive
https://bugs.webkit.org/show_bug.cgi?id=104594

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/track/track-remove-active-cue-crash.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updateActiveTextTrackCues):
(WebCore::HTMLMediaElement::textTrackAddCue):
(WebCore::HTMLMediaElement::textTrackRemoveCue): Remove the cue
from the active cue set as well.
* html/HTMLMediaElement.h:
(WebCore):

LayoutTests:

* media/track/track-remove-active-cue-crash-expected.txt: Added.
* media/track/track-remove-active-cue-crash.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (140833 => 140834)


--- trunk/LayoutTests/ChangeLog	2013-01-25 16:57:14 UTC (rev 140833)
+++ trunk/LayoutTests/ChangeLog	2013-01-25 16:58:54 UTC (rev 140834)
@@ -1,3 +1,13 @@
+2013-01-25  Victor Carbune  <[email protected]>
+
+        Heap-use-after-free in WebCore::TextTrackCue::isActive
+        https://bugs.webkit.org/show_bug.cgi?id=104594
+
+        Reviewed by Eric Carlson.
+
+        * media/track/track-remove-active-cue-crash-expected.txt: Added.
+        * media/track/track-remove-active-cue-crash.html: Added.
+
 2013-01-25  Sudarsana Nagineni  <[email protected]>
 
         Unreviewed EFL rebaseline.

Added: trunk/LayoutTests/media/track/track-remove-active-cue-crash-expected.txt (0 => 140834)


--- trunk/LayoutTests/media/track/track-remove-active-cue-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/track/track-remove-active-cue-crash-expected.txt	2013-01-25 16:58:54 UTC (rev 140834)
@@ -0,0 +1,15 @@
+Tests that removing an active cue does not crash the browser.
+
+** Add a text track to the video element **
+** Add a cue to the track with enter event listener. **
+
+** Play the video and remove cue when it becomes active. **
+RUN(video.play())
+EXPECTED (video.textTracks[0].activeCues.length == '1') OK
+
+** Remove the cue while it is active **
+
+No crash. PASS.
+
+END OF TEST
+

Added: trunk/LayoutTests/media/track/track-remove-active-cue-crash.html (0 => 140834)


--- trunk/LayoutTests/media/track/track-remove-active-cue-crash.html	                        (rev 0)
+++ trunk/LayoutTests/media/track/track-remove-active-cue-crash.html	2013-01-25 16:58:54 UTC (rev 140834)
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+        <script src=""
+        <script src=""
+        <script>
+        function removeActiveCue()
+        {
+            testExpected("video.textTracks[0].activeCues.length", 1);
+
+            consoleWrite("");
+            consoleWrite("** Remove the cue while it is active **");
+            video.textTracks[0].removeCue(video.textTracks[0].activeCues[0]);
+
+            consoleWrite("");
+            consoleWrite("No crash. PASS.");
+            consoleWrite("");
+
+            endTest();
+        }
+
+        function startTest()
+        {
+            findMediaElement();
+            video.src = "" '../content/test');
+
+            consoleWrite("** Add a text track to the video element **");
+            video.addTextTrack("captions", "regular captions track", "en");
+
+            consoleWrite("** Add a cue to the track with enter event listener. **");
+            var cue = new TextTrackCue(0.00, 4.00, "Random");
+            cue.addEventListener("enter", removeActiveCue);
+            video.textTracks[0].addCue(cue);
+
+            consoleWrite("");
+            consoleWrite("** Play the video and remove cue when it becomes active.  **");
+            run("video.play()");
+
+            video.textTracks[0].mode = "showing";
+          }
+        </script>
+    </head>
+
+    <body _onload_="startTest()">
+        <p>Tests that removing an active cue does not crash the browser.</p>
+        <video controls />
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (140833 => 140834)


--- trunk/Source/WebCore/ChangeLog	2013-01-25 16:57:14 UTC (rev 140833)
+++ trunk/Source/WebCore/ChangeLog	2013-01-25 16:58:54 UTC (rev 140834)
@@ -1,3 +1,20 @@
+2013-01-25  Victor Carbune  <[email protected]>
+
+        Heap-use-after-free in WebCore::TextTrackCue::isActive
+        https://bugs.webkit.org/show_bug.cgi?id=104594
+
+        Reviewed by Eric Carlson.
+
+        Test: media/track/track-remove-active-cue-crash.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::updateActiveTextTrackCues):
+        (WebCore::HTMLMediaElement::textTrackAddCue):
+        (WebCore::HTMLMediaElement::textTrackRemoveCue): Remove the cue
+        from the active cue set as well.
+        * html/HTMLMediaElement.h:
+        (WebCore):
+
 2013-01-25  Mike West  <[email protected]>
 
         Web Inspector: Cleanup console.* API MessageSource/Levels.

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (140833 => 140834)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-01-25 16:57:14 UTC (rev 140833)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-01-25 16:58:54 UTC (rev 140834)
@@ -1100,16 +1100,15 @@
     // media element (not the disabled ones) whose start times are less than or
     // equal to the current playback position and whose end times are greater
     // than the current playback position.
-    Vector<CueIntervalTree::IntervalType> currentCues;
+    CueList currentCues;
 
     // The user agent must synchronously unset [the text track cue active] flag
     // whenever ... the media element's readyState is changed back to HAVE_NOTHING.
     if (m_readyState != HAVE_NOTHING && m_player)
         currentCues = m_cueTree.allOverlaps(m_cueTree.createInterval(movieTime, movieTime));
 
-    Vector<CueIntervalTree::IntervalType> affectedCues;
-    Vector<CueIntervalTree::IntervalType> previousCues;
-    Vector<CueIntervalTree::IntervalType> missedCues;
+    CueList previousCues;
+    CueList missedCues;
 
     // 2 - Let other cues be a list of cues, initialized to contain all the cues
     // of hidden, showing, and showing by default text tracks of the media
@@ -1128,7 +1127,7 @@
     // end times are less than or equal to the current playback position.
     // Otherwise, let missed cues be an empty list.
     if (lastTime >= 0 && m_lastSeekTime < movieTime) {
-        Vector<CueIntervalTree::IntervalType> potentiallySkippedCues =
+        CueList potentiallySkippedCues =
             m_cueTree.allOverlaps(m_cueTree.createInterval(lastTime, movieTime));
 
         for (size_t i = 0; i < potentiallySkippedCues.size(); ++i) {
@@ -1419,7 +1418,7 @@
     // zero-length cues.
     double endTime = max(cue->startTime(), cue->endTime());
 
-    CueIntervalTree::IntervalType interval = m_cueTree.createInterval(cue->startTime(), endTime, cue.get());
+    CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, cue.get());
     if (!m_cueTree.contains(interval))
         m_cueTree.add(interval);
     updateActiveTextTrackCues(currentTime());
@@ -1431,7 +1430,13 @@
     // zero-length cues.
     double endTime = max(cue->startTime(), cue->endTime());
 
-    m_cueTree.remove(m_cueTree.createInterval(cue->startTime(), endTime, cue.get()));
+    CueInterval interval = m_cueTree.createInterval(cue->startTime(), endTime, cue.get());
+    m_cueTree.remove(interval);
+
+    size_t index = m_currentlyActiveCues.find(interval);
+    if (index != notFound)
+        m_currentlyActiveCues.remove(index);
+
     updateActiveTextTrackCues(currentTime());
 }
 

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (140833 => 140834)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2013-01-25 16:57:14 UTC (rev 140833)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2013-01-25 16:58:54 UTC (rev 140834)
@@ -72,7 +72,8 @@
 class InbandTextTrackPrivate;
 
 typedef PODIntervalTree<double, TextTrackCue*> CueIntervalTree;
-typedef Vector<CueIntervalTree::IntervalType> CueList;
+typedef CueIntervalTree::IntervalType CueInterval;
+typedef Vector<CueInterval> CueList;
 #endif
 
 // FIXME: The inheritance from MediaPlayerClient here should be private inheritance.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to