Subject: | Stripping apostrophes can segfault |
In Snowball.xs, Lingua-Stem-Snowball-0.93, _do_stem will perform an invalid read if the length of the input is less than 2, potentially triggering a segfault. The fix is to verify that the length of the input is no less than 2.
Marvin Humphrey
--- Snowball.old 2005-07-28 03:19:53.000000000 -0700
+++ Snowball.xs 2005-12-06 14:07:26.000000000 -0800
@@ -103,7 +103,7 @@
for(i=0;i<len;i++)
win[i] = tolower( (unsigned char)win[i] );
- if (strip_apostrophes == 1) {
+ if (strip_apostrophes == 1 && len >= 2) {
if (win[len - 2] == '\'')
SN_set_current(z, len - 2, win);
else if (win[1] == '\'')