From dffa922a90d9fcd1c37cdd46df10506fc644bd2a Mon Sep 17 00:00:00 2001 From: Jan Wijffels Date: Sun, 21 Oct 2018 22:27:45 +0200 Subject: [PATCH] Fix address sanitizer issue --- NEWS.md | 1 + src/cqdb/src/lookup3.c | 47 ++++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/NEWS.md b/NEWS.md index 5fe12cd..f125f21 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,7 @@ - Fix for as.crf when loaded from file and adding more arguments than just the file - added txt_feature as a simple feature extraction to identify if a word is capitalised, an email, an url or a number +- src/cqdb/src/lookup3.c, fix address sanitizer issue # CHANGES IN crfsuite VERSION 0.1.1 diff --git a/src/cqdb/src/lookup3.c b/src/cqdb/src/lookup3.c index 3bc29c3..e070881 100644 --- a/src/cqdb/src/lookup3.c +++ b/src/cqdb/src/lookup3.c @@ -312,27 +312,30 @@ uint32_t hashlittle( const void *key, size_t length, uint32_t initval) * still catch it and complain. The masking trick does make the hash * noticably faster for short strings (like English words). */ -#ifndef VALGRIND - - switch(length) - { - case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; - case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break; - case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break; - case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break; - case 8 : b+=k[1]; a+=k[0]; break; - case 7 : b+=k[1]&0xffffff; a+=k[0]; break; - case 6 : b+=k[1]&0xffff; a+=k[0]; break; - case 5 : b+=k[1]&0xff; a+=k[0]; break; - case 4 : a+=k[0]; break; - case 3 : a+=k[0]&0xffffff; break; - case 2 : a+=k[0]&0xffff; break; - case 1 : a+=k[0]&0xff; break; - case 0 : return c; /* zero length strings require no mixing */ - } - -#else /* make valgrind happy */ - +//#ifndef VALGRIND +// +// switch(length) +// { +// case 12: c+=k[2]; b+=k[1]; a+=k[0]; break; +// case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break; +// case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break; +// case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break; +// case 8 : b+=k[1]; a+=k[0]; break; +// case 7 : b+=k[1]&0xffffff; a+=k[0]; break; +// case 6 : b+=k[1]&0xffff; a+=k[0]; break; +// case 5 : b+=k[1]&0xff; a+=k[0]; break; +// case 4 : a+=k[0]; break; +// case 3 : a+=k[0]&0xffffff; break; +// case 2 : a+=k[0]&0xffff; break; +// case 1 : a+=k[0]&0xff; break; +// case 0 : return c; /* zero length strings require no mixing */ +// } +// +//#else /* make valgrind happy */ + + // ADDED TO FIX R CMD CHECK ADDRESSSANITIZER ISSUE + const uint8_t* k8; + k8 = (const uint8_t *)k; switch(length) { @@ -351,7 +354,7 @@ uint32_t hashlittle( const void *key, size_t length, uint32_t initval) case 0 : return c; } -#endif /* !valgrind */ +//#endif /* !valgrind */ } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) { const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */