Title: [123885] trunk/Source/WebKit/blackberry
Revision
123885
Author
[email protected]
Date
2012-07-27 10:39:54 -0700 (Fri, 27 Jul 2012)

Log Message

[BlackBerry] Switch InputHandler malloc use to fastMalloc for cases that should never fail
https://bugs.webkit.org/show_bug.cgi?id=92508

Patch by Mike Fenton <[email protected]> on 2012-07-27
Reviewed by Yong Li.

Replace common uses of malloc with fastMalloc rather
than trying to recover gracefully.  If we are truly
out of memory, crash before corruption occurs.

* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::InputHandler::spannableTextInRange):
(BlackBerry::WebKit::InputHandler::extractedTextRequest):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/ChangeLog (123884 => 123885)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-07-27 17:39:01 UTC (rev 123884)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-07-27 17:39:54 UTC (rev 123885)
@@ -1,3 +1,18 @@
+2012-07-27  Mike Fenton  <[email protected]>
+
+        [BlackBerry] Switch InputHandler malloc use to fastMalloc for cases that should never fail
+        https://bugs.webkit.org/show_bug.cgi?id=92508
+
+        Reviewed by Yong Li.
+
+        Replace common uses of malloc with fastMalloc rather
+        than trying to recover gracefully.  If we are truly
+        out of memory, crash before corruption occurs.
+
+        * WebKitSupport/InputHandler.cpp:
+        (BlackBerry::WebKit::InputHandler::spannableTextInRange):
+        (BlackBerry::WebKit::InputHandler::extractedTextRequest):
+
 2012-07-26  Nima Ghanavatian  <[email protected]>
 
         [BlackBerry] Remove synchronous spellchecking code

Modified: trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp (123884 => 123885)


--- trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-07-27 17:39:01 UTC (rev 123884)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/InputHandler.cpp	2012-07-27 17:39:54 UTC (rev 123885)
@@ -1586,12 +1586,10 @@
 
     WTF::String textString = elementText().substring(start, length);
 
-    spannable_string_t* pst = (spannable_string_t*)malloc(sizeof(spannable_string_t));
-    if (!pst) {
-        logAlways(LogLevelCritical, "InputHandler::spannableTextInRange error allocating spannable string.");
-        return 0;
-    }
+    spannable_string_t* pst = (spannable_string_t*)fastMalloc(sizeof(spannable_string_t));
 
+    // Don't use fastMalloc in case the string is unreasonably long. fastMalloc will
+    // crash immediately on failure.
     pst->str = (wchar_t*)malloc(sizeof(wchar_t) * (length + 1));
     if (!pst->str) {
         logAlways(LogLevelCritical, "InputHandler::spannableTextInRange Cannot allocate memory for string.\n");
@@ -1651,7 +1649,7 @@
     if (!isActiveTextEdit())
         return 0;
 
-    extracted_text_t* extractedText = (extracted_text_t *)malloc(sizeof(extracted_text_t));
+    extracted_text_t* extractedText = (extracted_text_t *)fastMalloc(sizeof(extracted_text_t));
 
     // 'flags' indicates whether the text is being monitored. This is not currently used.
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to