Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Unified Diff: src/hunspell/suggestmgr.cxx

Issue 300233002: [hunspell] Fix read from uninit memory. (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/hunspell.git@master
Patch Set: Fix nit. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « google.patch ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hunspell/suggestmgr.cxx
diff --git a/src/hunspell/suggestmgr.cxx b/src/hunspell/suggestmgr.cxx
index c3477df7af93583a5f3bf93c35628166410b9048..f60007bedfd35098785719c61a56f224eb85069e 100644
--- a/src/hunspell/suggestmgr.cxx
+++ b/src/hunspell/suggestmgr.cxx
@@ -2108,16 +2108,14 @@ void SuggestMgr::lcs(const char * s, const char * s2, int * l1, int * l2, char *
m = strlen(s);
n = strlen(s2);
}
- c = (char *) malloc((m + 1) * (n + 1));
- b = (char *) malloc((m + 1) * (n + 1));
+ c = (char *) calloc(m + 1, n + 1);
+ b = (char *) calloc(m + 1, n + 1);
if (!c || !b) {
if (c) free(c);
if (b) free(b);
*result = NULL;
return;
}
- for (i = 1; i <= m; i++) c[i*(n+1)] = 0;
- for (j = 0; j <= n; j++) c[j] = 0;
for (i = 1; i <= m; i++) {
for (j = 1; j <= n; j++) {
if ( ((utf8) && (*((short *) su+i-1) == *((short *)su2+j-1)))
« no previous file with comments | « google.patch ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698