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

Side by Side 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: Updated instructions. Created 6 years, 6 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 unified diff | Download patch
« no previous file with comments | « google.patch ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "license.hunspell" 1 #include "license.hunspell"
2 #include "license.myspell" 2 #include "license.myspell"
3 3
4 #include <stdlib.h> 4 #include <stdlib.h>
5 #include <string.h> 5 #include <string.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include "suggestmgr.hxx" 9 #include "suggestmgr.hxx"
10 #include "htypes.hxx" 10 #include "htypes.hxx"
(...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 char * c; 2101 char * c;
2102 int i; 2102 int i;
2103 int j; 2103 int j;
2104 if (utf8) { 2104 if (utf8) {
2105 m = u8_u16(su, MAXSWL, s); 2105 m = u8_u16(su, MAXSWL, s);
2106 n = u8_u16(su2, MAXSWL, s2); 2106 n = u8_u16(su2, MAXSWL, s2);
2107 } else { 2107 } else {
2108 m = strlen(s); 2108 m = strlen(s);
2109 n = strlen(s2); 2109 n = strlen(s2);
2110 } 2110 }
2111 c = (char *) malloc((m + 1) * (n + 1)); 2111 c = (char *) calloc((m + 1), (n + 1));
2112 b = (char *) malloc((m + 1) * (n + 1)); 2112 b = (char *) calloc((m + 1), (n + 1));
Avi (use Gerrit) 2014/05/27 20:40:49 The parentheses around m+1 and n+1 aren't necessar
2113 if (!c || !b) { 2113 if (!c || !b) {
2114 if (c) free(c); 2114 if (c) free(c);
2115 if (b) free(b); 2115 if (b) free(b);
2116 *result = NULL; 2116 *result = NULL;
2117 return; 2117 return;
2118 } 2118 }
2119 for (i = 1; i <= m; i++) c[i*(n+1)] = 0;
2120 for (j = 0; j <= n; j++) c[j] = 0;
2121 for (i = 1; i <= m; i++) { 2119 for (i = 1; i <= m; i++) {
2122 for (j = 1; j <= n; j++) { 2120 for (j = 1; j <= n; j++) {
2123 if ( ((utf8) && (*((short *) su+i-1) == *((short *)su2+j-1))) 2121 if ( ((utf8) && (*((short *) su+i-1) == *((short *)su2+j-1)))
2124 || ((!utf8) && ((*(s+i-1)) == (*(s2+j-1))))) { 2122 || ((!utf8) && ((*(s+i-1)) == (*(s2+j-1))))) {
2125 c[i*(n+1) + j] = c[(i-1)*(n+1) + j-1]+1; 2123 c[i*(n+1) + j] = c[(i-1)*(n+1) + j-1]+1;
2126 b[i*(n+1) + j] = LCS_UPLEFT; 2124 b[i*(n+1) + j] = LCS_UPLEFT;
2127 } else if (c[(i-1)*(n+1) + j] >= c[i*(n+1) + j-1]) { 2125 } else if (c[(i-1)*(n+1) + j] >= c[i*(n+1) + j-1]) {
2128 c[i*(n+1) + j] = c[(i-1)*(n+1) + j]; 2126 c[i*(n+1) + j] = c[(i-1)*(n+1) + j];
2129 b[i*(n+1) + j] = LCS_UP; 2127 b[i*(n+1) + j] = LCS_UP;
2130 } else { 2128 } else {
(...skipping 24 matching lines...) Expand all
2155 len++; 2153 len++;
2156 i--; 2154 i--;
2157 j--; 2155 j--;
2158 } else if (result[i*(n+1) + j] == LCS_UP) { 2156 } else if (result[i*(n+1) + j] == LCS_UP) {
2159 i--; 2157 i--;
2160 } else j--; 2158 } else j--;
2161 } 2159 }
2162 free(result); 2160 free(result);
2163 return len; 2161 return len;
2164 } 2162 }
OLDNEW
« 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