[Libreoffice-commits] libexttextcat.git: src/fingerprint.c src/utf8misc.c
Stephan Bergmann
sbergman at redhat.com
Wed Sep 20 11:14:55 UTC 2017
src/fingerprint.c | 4 ++--
src/utf8misc.c | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
New commits:
commit 14b6457904397d94602340ee3f61db13201430b4
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Sep 19 16:51:28 2017 +0200
Silence various -fsanitize=shift-base
...that were observed with a UBSan LibreOffice build, when opening LibreOffice's
writerfilter/qa/cppunittests/rtftok/data/pass/EDB-18940-1.rtf. (Downstream
patch at <https://cgit.freedesktop.org/libreoffice/core/commit/
?id=67141d8331f9cb85751a4747986774b53b7f4a77> "external/libexttextcat: Silence
various -fsanitize=shift-base".)
diff --git a/src/fingerprint.c b/src/fingerprint.c
index 428b8df..3c8d242 100644
--- a/src/fingerprint.c
+++ b/src/fingerprint.c
@@ -128,12 +128,12 @@ typedef struct table_s
*/
static uint4 simplehash(const char *p, int len)
{
- sint4 h = len * 13;
+ uint4 h = len * 13;
while (*p)
{
h = (h << 5) - h + *p++;
}
- return (uint4) h;
+ return h;
}
/* increases frequency of ngram(p,len) */
diff --git a/src/utf8misc.c b/src/utf8misc.c
index 046d96b..e76c25f 100644
--- a/src/utf8misc.c
+++ b/src/utf8misc.c
@@ -61,7 +61,7 @@ const char *utf8_next_char(const char *str)
* if the first bit of the current char is 1 then *str is an escape
* character
*/
- char escape_char = ((*str & WEIGHT_MASK) << 1);
+ unsigned char escape_char = ((*str & WEIGHT_MASK) << 1);
/*
* and we use it to count (by bit translation) following characters
@@ -99,7 +99,7 @@ int utf8_charcopy(const char *str, char *dest)
* then str[pointer] is an escape character and we use it to count
* following characters (only the weightest part)
*/
- char escape_char = ((str[pointer] & WEIGHT_MASK) << 1);
+ unsigned char escape_char = ((str[pointer] & WEIGHT_MASK) << 1);
/*
* every step, we move the byte of 1 bit left, when first bit is 0,
@@ -138,7 +138,7 @@ int utf8_issame(char *lex, char *key, int len)
* (only the weightest part)
*/
- char escape_char = ((key[pointer] & WEIGHT_MASK) << 1);
+ unsigned char escape_char = ((key[pointer] & WEIGHT_MASK) << 1);
while (escape_char & ESCAPE_MASK && key[pointer] == lex[pointer])
{
More information about the Libreoffice-commits
mailing list