Title: [147800] trunk
Revision
147800
Author
cfleiz...@apple.com
Date
2013-04-05 14:51:17 -0700 (Fri, 05 Apr 2013)

Log Message

WebSpeech: crash at WebCore::SpeechSynthesis::speak
https://bugs.webkit.org/show_bug.cgi?id=113937

Reviewed by Tim Horton.

Source/WebCore:

Protect against the case when invalid data is passed in.

Test: platform/mac/fast/speechsynthesis/speech-synthesis-crash-on-bad-utterance.html

* Modules/speech/SpeechSynthesis.cpp:
(WebCore::SpeechSynthesis::speak):
* Modules/speech/SpeechSynthesisUtterance.cpp:
(WebCore::SpeechSynthesisUtterance::setVoice):

LayoutTests:

* platform/mac/fast/speechsynthesis/speech-synthesis-crash-on-bad-utterance-expected.txt: Added.
* platform/mac/fast/speechsynthesis/speech-synthesis-crash-on-bad-utterance.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (147799 => 147800)


--- trunk/LayoutTests/ChangeLog	2013-04-05 21:47:17 UTC (rev 147799)
+++ trunk/LayoutTests/ChangeLog	2013-04-05 21:51:17 UTC (rev 147800)
@@ -1,3 +1,13 @@
+2013-04-05  Chris Fleizach  <cfleiz...@apple.com>
+
+        WebSpeech: crash at WebCore::SpeechSynthesis::speak
+        https://bugs.webkit.org/show_bug.cgi?id=113937
+
+        Reviewed by Tim Horton.
+
+        * platform/mac/fast/speechsynthesis/speech-synthesis-crash-on-bad-utterance-expected.txt: Added.
+        * platform/mac/fast/speechsynthesis/speech-synthesis-crash-on-bad-utterance.html: Added.
+
 2013-04-05  Rijubrata Bhaumik  <rijubrata.bhau...@intel.com>
 
         [EFL] Enable indexed database

Added: trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-crash-on-bad-utterance-expected.txt (0 => 147800)


--- trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-crash-on-bad-utterance-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-crash-on-bad-utterance-expected.txt	2013-04-05 21:51:17 UTC (rev 147800)
@@ -0,0 +1,9 @@
+This tests that passing in the wrong type of data won't crash speech synthesis code
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-crash-on-bad-utterance.html (0 => 147800)


--- trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-crash-on-bad-utterance.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-crash-on-bad-utterance.html	2013-04-05 21:51:17 UTC (rev 147800)
@@ -0,0 +1,28 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<div id="console"></div>
+
+<script>
+
+    description("This tests that passing in the wrong type of data won't crash speech synthesis code");
+
+     // Don't crash. Speak is supposed to take an utterance, not a string.
+     speechSynthesis.speak('Hello World');
+
+     // Don't crash. An utterance voice is supposed to take a voice object, not a string.
+     var x = new SpeechSynthesisUtterance('Hello World');
+     x.voice = "asdf";
+
+     // Don't crash. An utterance is supposed to take a string, not a number.
+     x = new SpeechSynthesisUtterance(223);
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (147799 => 147800)


--- trunk/Source/WebCore/ChangeLog	2013-04-05 21:47:17 UTC (rev 147799)
+++ trunk/Source/WebCore/ChangeLog	2013-04-05 21:51:17 UTC (rev 147800)
@@ -1,3 +1,19 @@
+2013-04-05  Chris Fleizach  <cfleiz...@apple.com>
+
+        WebSpeech: crash at WebCore::SpeechSynthesis::speak
+        https://bugs.webkit.org/show_bug.cgi?id=113937
+
+        Reviewed by Tim Horton.
+
+        Protect against the case when invalid data is passed in.
+
+        Test: platform/mac/fast/speechsynthesis/speech-synthesis-crash-on-bad-utterance.html
+
+        * Modules/speech/SpeechSynthesis.cpp:
+        (WebCore::SpeechSynthesis::speak):
+        * Modules/speech/SpeechSynthesisUtterance.cpp:
+        (WebCore::SpeechSynthesisUtterance::setVoice):
+
 2013-04-05  Antti Koivisto  <an...@apple.com>
 
         Throttle compositing layer flushes during page loading

Modified: trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp (147799 => 147800)


--- trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp	2013-04-05 21:47:17 UTC (rev 147799)
+++ trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp	2013-04-05 21:51:17 UTC (rev 147800)
@@ -102,6 +102,9 @@
 
 void SpeechSynthesis::speak(SpeechSynthesisUtterance* utterance)
 {
+    if (!utterance)
+        return;
+    
     m_utteranceQueue.append(utterance);
     
     // If the queue was empty, speak this immediately and add it to the queue.

Modified: trunk/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp (147799 => 147800)


--- trunk/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp	2013-04-05 21:47:17 UTC (rev 147799)
+++ trunk/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp	2013-04-05 21:51:17 UTC (rev 147800)
@@ -64,6 +64,9 @@
 
 void SpeechSynthesisUtterance::setVoice(SpeechSynthesisVoice* voice)
 {
+    if (!voice)
+        return;
+    
     // Cache our own version of the SpeechSynthesisVoice so that we don't have to do some lookup
     // to go from the platform voice back to the speech synthesis voice in the read property.
     m_voice = voice;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to