Bug 710940 - Make sure our implementation of get_current_cs does not return null, in order to respect hunspell's assumptions; r=smaug
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 09 Jan 2012 19:02:43 -0500
changeset 84070 b4778618b053c04fb8a99bdfde3c7626146b2c50
parent 84069 fd89376a7ef287f26badf04b50027abd25143e82
child 84071 6a0de913a0429d0aae8518e5de030a72859afa9c
push id21820
push usermak77@bonardo.net
push dateTue, 10 Jan 2012 09:03:21 +0000
treeherdermozilla-central@01d69766026d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs710940
milestone12.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 710940 - Make sure our implementation of get_current_cs does not return null, in order to respect hunspell's assumptions; r=smaug
extensions/spellcheck/hunspell/src/README.hunspell
extensions/spellcheck/hunspell/src/csutil.cpp
--- a/extensions/spellcheck/hunspell/src/README.hunspell
+++ b/extensions/spellcheck/hunspell/src/README.hunspell
@@ -31,17 +31,17 @@
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 ******* END LICENSE BLOCK *******
 
 Hunspell Version:   1.3.2
-Additional Patches: 694002, 710967
+Additional Patches: 694002, 710967, 710940
 
 Hunspell Author: László Németh
 MySpell Author: Kevin Hendricks & David Einstein
 
 Hunspell is a spell checker and morphological analyser library. Hunspell
 is based on OpenOffice.org's Myspell. Documentation, tests, and examples
 are available at http://hunspell.sourceforge.net.
 
--- a/extensions/spellcheck/hunspell/src/csutil.cpp
+++ b/extensions/spellcheck/hunspell/src/csutil.cpp
@@ -5518,39 +5518,44 @@ struct cs_info * get_current_cs(const ch
 
   return ccs;
 }
 #else
 // XXX This function was rewritten for mozilla. Instead of storing the
 // conversion tables static in this file, create them when needed
 // with help the mozilla backend.
 struct cs_info * get_current_cs(const char * es) {
-  struct cs_info *ccs;
+  struct cs_info *ccs = new cs_info[256];
+  // Initialze the array with dummy data so that we wouldn't need
+  // to return null in case of failures.
+  for (int i = 0; i <= 0xff; ++i) {
+    ccs[i].ccase = false;
+    ccs[i].clower = i;
+    ccs[i].cupper = i;
+  }
 
   nsCOMPtr<nsIUnicodeEncoder> encoder; 
   nsCOMPtr<nsIUnicodeDecoder> decoder; 
 
   nsresult rv;
   nsCOMPtr<nsICharsetConverterManager> ccm = do_GetService(kCharsetConverterManagerCID, &rv);
   if (NS_FAILED(rv))
-    return nsnull;
+    return ccs;
 
   rv = ccm->GetUnicodeEncoder(es, getter_AddRefs(encoder));
   if (NS_FAILED(rv))
-    return nsnull;
+    return ccs;
   encoder->SetOutputErrorBehavior(encoder->kOnError_Signal, nsnull, '?');
   rv = ccm->GetUnicodeDecoder(es, getter_AddRefs(decoder));
   if (NS_FAILED(rv))
-    return nsnull;
+    return ccs;
   decoder->SetInputErrorBehavior(decoder->kOnError_Signal);
 
   if (NS_FAILED(rv))
-    return nsnull;
-
-  ccs = new cs_info[256];
+    return ccs;
 
   for (unsigned int i = 0; i <= 0xff; ++i) {
     bool success = false;
     // We want to find the upper/lowercase equivalents of each byte
     // in this 1-byte character encoding.  Call our encoding/decoding
     // APIs separately for each byte since they may reject some of the
     // bytes, and we want to handle errors separately for each byte.
     char lower, upper;