You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2011/05/20 17:58:49 UTC

[lucy-commits] svn commit: r1125442 - /incubator/lucy/trunk/core/Lucy/Index/SortCache/TextSortCache.c

Author: marvin
Date: Fri May 20 15:58:49 2011
New Revision: 1125442

URL: http://svn.apache.org/viewvc?rev=1125442&view=rev
Log:
Sanity check UTF-8 validity of text sort cache character data.

Modified:
    incubator/lucy/trunk/core/Lucy/Index/SortCache/TextSortCache.c

Modified: incubator/lucy/trunk/core/Lucy/Index/SortCache/TextSortCache.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/SortCache/TextSortCache.c?rev=1125442&r1=1125441&r2=1125442&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/SortCache/TextSortCache.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/SortCache/TextSortCache.c Fri May 20 15:58:49 2011
@@ -113,6 +113,11 @@ TextSortCache_value(TextSortCache *self,
         InStream_Seek(self->dat_in, offset);
         InStream_Read_Bytes(self->dat_in, ptr, (size_t)len);
         ptr[len] = '\0';
+        if (!StrHelp_utf8_valid(ptr, (size_t)len)) {
+            CB_Set_Size((CharBuf*)blank, 0);
+            THROW(ERR, "Invalid UTF-8 at %i64 in %o", offset,
+                  InStream_Get_Filename(self->dat_in));
+        }
         CB_Set_Size((CharBuf*)blank, (size_t)len);
     }
     return blank;