summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDom Lachowicz <domlachowicz@gmail.com>2005-09-01 01:06:39 +0000
committerDom Lachowicz <domlachowicz@gmail.com>2005-09-01 01:06:39 +0000
commit1bb0062613c32c5e79d8221c63f58bd969cde884 (patch)
treea633f4489de4ef04eba4db843a086e2a9cc674e2
parentf16fc03ed8767aff1c6c6732cf7b8e2b21242ef1 (diff)
downloadenchant-1bb0062613c32c5e79d8221c63f58bd969cde884.tar.gz
apply various memory leak and correctness patches from debian; http://ftp.debian.org/debian/pool/main/m/myspell/myspell_3.0+pre3.1-16.diff.gz
git-svn-id: svn+ssh://svn.abisource.com/svnroot/enchant/trunk@21060 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6
-rw-r--r--src/myspell/affixmgr.cxx2
-rw-r--r--src/myspell/csutil.cxx4
-rw-r--r--src/myspell/suggestmgr.cxx41
3 files changed, 27 insertions, 20 deletions
diff --git a/src/myspell/affixmgr.cxx b/src/myspell/affixmgr.cxx
index 87ca583..3a5714b 100644
--- a/src/myspell/affixmgr.cxx
+++ b/src/myspell/affixmgr.cxx
@@ -872,7 +872,7 @@ char * AffixMgr::get_try_string()
char * AffixMgr::get_compound()
{
if (! compound ) return NULL;
- return mystrdup(compound);
+ return compound;
}
// utility method to look up root words in hash table
diff --git a/src/myspell/csutil.cxx b/src/myspell/csutil.cxx
index 0ecafda..73065f1 100644
--- a/src/myspell/csutil.cxx
+++ b/src/myspell/csutil.cxx
@@ -3836,7 +3836,7 @@ struct cs_info * get_current_cs(const char * es) {
}
}
return ccs;
-};
+}
@@ -3869,5 +3869,5 @@ const char * get_default_enc(const char * lang) {
}
}
return NULL;
-};
+}
diff --git a/src/myspell/suggestmgr.cxx b/src/myspell/suggestmgr.cxx
index 4a756b3..e008b0e 100644
--- a/src/myspell/suggestmgr.cxx
+++ b/src/myspell/suggestmgr.cxx
@@ -118,7 +118,7 @@ int SuggestMgr::map_related(const char * word, int i, char** wlst, int ns, const
for (int j = 0; j < nummap; j++) {
if (strchr(maptable[j].set,c) != 0) {
in_map = 1;
- char * newword = strdup(word);
+ char * newword = mystrdup(word);
for (int k = 0; k < maptable[j].len; k++) {
*(newword + i) = *(maptable[j].set + k);
ns = map_related(newword, (i+1), wlst, ns, maptable, nummap);
@@ -398,7 +398,7 @@ int SuggestMgr::ngsuggest(char** wlst, char * word, HashMgr* pHMgr)
int thresh = 0;
char * mw = NULL;
for (int sp = 1; sp < 4; sp++) {
- mw = strdup(word);
+ mw = mystrdup(word);
for (int k=sp; k < n; k+=4) *(mw + k) = '*';
thresh = thresh + ngram(n, word, mw, NGRAM_ANY_MISMATCH);
free(mw);
@@ -431,21 +431,28 @@ int SuggestMgr::ngsuggest(char** wlst, char * word, HashMgr* pHMgr)
rp->astr, rp->alen);
for (int k = 0; k < nw; k++) {
sc = ngram(n, word, glst[k].word, NGRAM_ANY_MISMATCH);
- if (sc > thresh) {
- if (sc > gscore[lp]) {
- if (guess[lp]) free (guess[lp]);
- gscore[lp] = sc;
- guess[lp] = glst[k].word;
- lval = sc;
- for (j=0; j < MAX_GUESS; j++)
- if (gscore[j] < lval) {
- lp = j;
- lval = gscore[j];
- }
- } else {
- free (glst[k].word);
- }
- }
+ if (sc > thresh)
+ {
+ if (sc > gscore[lp])
+ {
+ if (guess[lp]) free(guess[lp]);
+ gscore[lp] = sc;
+ guess[lp] = glst[k].word;
+ glst[k].word = NULL;
+ lval = sc;
+ for (j=0; j < MAX_GUESS; j)
+ {
+ if (gscore[j] < lval)
+ {
+ lp = j;
+ lval = gscore[j];
+ }
+ }
+ }
+ }
+ free (glst[k].word);
+ glst[k].word = NULL;
+ glst[k].allow = 0;
}
}
}