blob: d6e5cce4a37049db505858893f306aa5ab59ac25 [file] [log] [blame]
==== //depot//src/hunspell/license.hunspell
--- /google/src/files/a/depot//src/hunspell/license.hunspell 2013-07-24 23:12:12.000000000 -0400
+++ /google/src/files/b/depot//src/hunspell/license.hunspell 2013-10-01 01:04:03.000000000 -0400
@@ -56,4 +56,6 @@
*
* ***** END LICENSE BLOCK ***** */
+/* This isn't needed to be compiled.
#include "config.h"
+*/
==== //depot//src/hunspell/hunspell.cxx
--- /google/src/files/a/depot//src/hunspell/hunspell.cxx 2013-07-24 23:12:12.000000000 -0400
+++ /google/src/files/b/depot//src/hunspell/hunspell.cxx 2013-10-01 01:04:03.000000000 -0400
@@ -8,9 +8,11 @@
#include "hunspell.hxx"
#include "hunspell.h"
+/* This is not required
#ifndef MOZILLA_CLIENT
# include "config.h"
#endif
+*/
#include "csutil.hxx"
Hunspell::Hunspell(const char * affpath, const char * dpath, const char * key)
==== //depot//src/hunspell/csutil.cxx
--- /google/src/files/a/depot//src/hunspell/csutil.cxx 2013-07-24 23:12:12.000000000 -0400
+++ /google/src/files/b/depot//src/hunspell/csutil.cxx 2013-10-01 01:04:03.000000000 -0400
@@ -10,13 +10,6 @@
#include "atypes.hxx"
#include "langnum.hxx"
-// Unicode character encoding information
-struct unicode_info {
- unsigned short c;
- unsigned short cupper;
- unsigned short clower;
-};
-
#ifdef OPENOFFICEORG
# include <unicode/uchar.h>
#else
==== //depot//src/hunspell/csutil.hxx
--- /google/src/files/a/depot//src/hunspell/csutil.hxx 2013-07-24 23:12:12.000000000 -0400
+++ /google/src/files/b/depot//src/hunspell/csutil.hxx 2013-10-01 01:04:03.000000000 -0400
@@ -116,6 +116,13 @@
unsigned char cupper;
};
+// Unicode character encoding information
+struct unicode_info {
+ unsigned short c;
+ unsigned short cupper;
+ unsigned short clower;
+};
+
LIBHUNSPELL_DLL_EXPORTED int initialize_utf_tbl();
LIBHUNSPELL_DLL_EXPORTED void free_utf_tbl();
LIBHUNSPELL_DLL_EXPORTED unsigned short unicodetoupper(unsigned short c, int langnum);
==== //depot//src/hunspell/suggestmgr.cxx
--- /google/src/files/a/depot//src/hunspell/suggestmgr.cxx 2013-07-24 23:12:12.000000000 -0400
+++ /google/src/files/b/depot//src/hunspell/suggestmgr.cxx 2013-10-01 01:04:03.000000000 -0400
@@ -155,10 +155,13 @@
if (utf8) {
wl = u8_u16(word_utf, MAXSWL, word);
- if (wl == -1) {
- *slst = wlst;
- return nsug;
- }
+ // Added to handle wrong encoded UTF-8 strings - jiho@google.com
+ if (wl <= 0) {
+ if (!*slst) {
+ free(wlst);
+ }
+ return -1;
+ }
}
for (int cpdsuggest=0; (cpdsuggest<2) && (nocompoundtwowords==0); cpdsuggest++) {
--- /google/src/files/a/depot//src/hunspell/affixmgr.cxx 2013-07-24 23:12:12.000000000 -0400
+++ /google/src/files/b/depot//src/hunspell/affixmgr.cxx 2013-10-01 01:04:03.000000000 -0400
@@ -8,6 +8,7 @@
#include <vector>
+#include "base/scoped_ptr.h"
#include "affixmgr.hxx"
#include "affentry.hxx"
#include "langnum.hxx"
@@ -1364,9 +1365,14 @@
// check compound patterns
int AffixMgr::defcpd_check(hentry *** words, short wnum, hentry * rv, hentry ** def, char all)
{
- signed short btpp[MAXWORDLEN]; // metacharacter (*, ?) positions for backtracking
- signed short btwp[MAXWORDLEN]; // word positions for metacharacters
- int btnum[MAXWORDLEN]; // number of matched characters in metacharacter positions
+ // Note(jiho@google.com): Changed to use scoped_ptr to avoid 64KB stack size
+ // problem.
+ scoped_array<signed short> scoped_btpp(new signed short[MAXWORDLEN]);
+ signed short * btpp = scoped_btpp.get(); // metacharacter (*, ?) positions for backtracking
+ scoped_array<signed short> scoped_btwp(new signed short[MAXWORDLEN]);
+ signed short * btwp = scoped_btwp.get(); // word positions for metacharacters
+ scoped_array<int> scoped_btnum(new int[MAXWORDLEN]);
+ int * btnum = scoped_btnum.get(); // number of matched characters in metacharacter positions
short bt = 0;
int i, j;
int ok;
@@ -1531,8 +1537,18 @@
short oldnumsyllable, oldnumsyllable2, oldwordnum, oldwordnum2;
struct hentry * rv = NULL;
struct hentry * rv_first;
- struct hentry * rwords[MAXWORDLEN]; // buffer for COMPOUND pattern checking
- char st [MAXWORDUTF8LEN + 4];
+
+ // NOTE: This can not be a scoped_array because
+ // "new hentry*[MAXWORDLEN]" is compiled to call malloc() which is not
+ // compatible with scoped_ptr.
+ // scoped_array<struct hentry*> rwords(new hentry*[MAXWORDLEN]);
+ struct hentry ** rwords = // buffer for COMPOUND pattern checking
+ (struct hentry**) malloc(sizeof(struct hentry*) * (MAXWORDLEN));
+
+ // Note(jiho@google.com): Changed to use scoped_ptr to avoid 64KB stack size
+ // problem.
+ scoped_array<char> scoped_st(new char[MAXWORDUTF8LEN + 4]);
+ char * st = scoped_st.get();
char ch = '\0';
int cmin;
int cmax;
@@ -1557,7 +1573,10 @@
// go to end of the UTF-8 character
if (utf8) {
for (; (st[i] & 0xc0) == 0x80; i++);
- if (i >= cmax) return NULL;
+ if (i >= cmax) {
+ free(rwords);
+ return NULL;
+ }
}
words = oldwords;
@@ -1612,8 +1631,8 @@
(compoundmiddle && wordnum && !words && !onlycpdrule &&
TESTAFF(rv->astr, compoundmiddle, rv->alen)) ||
(numdefcpd && onlycpdrule &&
- ((!words && !wordnum && defcpd_check(&words, wnum, rv, (hentry **) &rwords, 0)) ||
- (words && defcpd_check(&words, wnum, rv, (hentry **) &rwords, 0))))) ||
+ ((!words && !wordnum && defcpd_check(&words, wnum, rv, rwords, 0)) ||
+ (words && defcpd_check(&words, wnum, rv, rwords, 0))))) ||
(scpd != 0 && checkcpdtable[scpd-1].cond != FLAG_NULL &&
!TESTAFF(rv->astr, checkcpdtable[scpd-1].cond, rv->alen)))
) {
@@ -1693,6 +1712,7 @@
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) ||
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen) ||
(is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) {
+ free(rwords);
return NULL;
}
@@ -1784,7 +1804,10 @@
if (rv && forceucase && (rv) &&
(TESTAFF(rv->astr, forceucase, rv->alen)) && !(info && *info & SPELL_ORIGCAP)) rv = NULL;
- if (rv && words && words[wnum + 1]) return rv_first;
+ if (rv && words && words[wnum + 1]) {
+ free(rwords);
+ return rv_first;
+ }
oldnumsyllable2 = numsyllable;
oldwordnum2 = wordnum;
@@ -1805,7 +1828,10 @@
// check forbiddenwords
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) ||
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen) ||
- (is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) return NULL;
+ (is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) {
+ free(rwords);
+ return NULL;
+ }
// second word is acceptable, as a root?
// hungarian conventions: compounding is acceptable,
@@ -1833,6 +1859,7 @@
TESTAFF(rv->astr, checkcpdtable[scpd-1].cond2, rv->alen))
)
{
+ free(rwords);
// forbid compound word, if it is a non compound word with typical fault
if (checkcompoundrep && cpdrep_check(word,len)) return NULL;
return rv_first;
@@ -1853,7 +1880,10 @@
if (!rv && numdefcpd && words) {
rv = affix_check((word+i),strlen(word+i), 0, IN_CPD_END);
- if (rv && defcpd_check(&words, wnum + 1, rv, NULL, 1)) return rv_first;
+ if (rv && defcpd_check(&words, wnum + 1, rv, NULL, 1)) {
+ free(rwords);
+ return rv_first;
+ }
rv = NULL;
}
@@ -1882,7 +1912,10 @@
// check forbiddenwords
if ((rv) && (rv->astr) && (TESTAFF(rv->astr, forbiddenword, rv->alen) ||
TESTAFF(rv->astr, ONLYUPCASEFLAG, rv->alen) ||
- (is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) return NULL;
+ (is_sug && nosuggest && TESTAFF(rv->astr, nosuggest, rv->alen)))) {
+ free(rwords);
+ return NULL;
+ }
// pfxappnd = prefix of word+i, or NULL
// calculate syllable number of prefix.
@@ -1936,7 +1969,11 @@
(!checkcompounddup || (rv != rv_first))
)) {
// forbid compound word, if it is a non compound word with typical fault
- if (checkcompoundrep && cpdrep_check(word, len)) return NULL;
+ if (checkcompoundrep && cpdrep_check(word, len)) {
+ free(rwords);
+ return NULL;
+ }
+ free(rwords);
return rv_first;
}
@@ -1958,7 +1995,10 @@
if (checkcompoundrep || forbiddenword) {
struct hentry * rv2 = NULL;
- if (checkcompoundrep && cpdrep_check(word, len)) return NULL;
+ if (checkcompoundrep && cpdrep_check(word, len)) {
+ free(rwords);
+ return NULL;
+ }
// check first part
if (strncmp(rv->word, word + i, rv->blen) == 0) {
@@ -1975,12 +2015,14 @@
if (!rv2) rv2 = affix_check(word, len);
if (rv2 && rv2->astr && TESTAFF(rv2->astr, forbiddenword, rv2->alen) &&
(strncmp(rv2->word, st, i + rv->blen) == 0)) {
+ free(rwords);
return NULL;
}
}
*(st + i + rv->blen) = r;
}
}
+ free(rwords);
return rv_first;
}
} while (striple && !checkedstriple); // end of striple loop
@@ -2019,6 +2061,7 @@
}
+ free(rwords);
return NULL;
}
@@ -2034,8 +2077,13 @@
struct hentry * rv = NULL;
struct hentry * rv_first;
- struct hentry * rwords[MAXWORDLEN]; // buffer for COMPOUND pattern checking
- char st [MAXWORDUTF8LEN + 4];
+ // Note(jiho@google.com): Changed to use malloc to avoid stack overflow.
+ struct hentry ** rwords = // buffer for COMPOUND pattern checking
+ (struct hentry**) malloc(sizeof(struct hentry*) * (MAXWORDLEN));
+ // Note(jiho@google.com): Changed to use scoped_ptr to avoid 64KB stack size
+ // problem.
+ scoped_array<char> scoped_st(new char[MAXWORDUTF8LEN + 4]);
+ char * st = scoped_st.get();
char ch;
int checked_prefix;
@@ -2060,7 +2108,10 @@
// go to end of the UTF-8 character
if (utf8) {
for (; (st[i] & 0xc0) == 0x80; i++);
- if (i >= cmax) return 0;
+ if (i >= cmax) {
+ free(rwords);
+ return NULL;
+ }
}
words = oldwords;
@@ -2094,8 +2145,8 @@
(compoundmiddle && wordnum && !words && !onlycpdrule &&
TESTAFF(rv->astr, compoundmiddle, rv->alen)) ||
(numdefcpd && onlycpdrule &&
- ((!words && !wordnum && defcpd_check(&words, wnum, rv, (hentry **) &rwords, 0)) ||
- (words && defcpd_check(&words, wnum, rv, (hentry **) &rwords, 0))))
+ ((!words && !wordnum && defcpd_check(&words, wnum, rv, rwords, 0)) ||
+ (words && defcpd_check(&words, wnum, rv, rwords, 0))))
))) {
rv = rv->next_homonym;
}
@@ -2289,6 +2340,7 @@
}
mystrcat(*result, "\n", MAXLNLEN);
ok = 1;
+ free(rwords);
return 0;
}
@@ -2488,6 +2540,7 @@
} while (numdefcpd && oldwordnum == 0 && !onlycpdrule && (onlycpdrule = 1)); // end of onlycpd loop
}
+ free(rwords);
return 0;
}