]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Issue #175: disable the fast-and-loose code in hashlittle() when running with Address...
authorEric Haszlakiewicz <erh+git@nimenees.com>
Wed, 8 Jun 2016 03:24:59 +0000 (03:24 +0000)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Wed, 8 Jun 2016 03:24:59 +0000 (03:24 +0000)
linkhash.c

index 4ea4921bc25e9f1245bc700dfc30088708e0d55d..1a5c1b8bfc979081e9b5cad0a06c39d8224ad0ea 100644 (file)
@@ -289,8 +289,19 @@ static uint32_t hashlittle( const void *key, size_t length, uint32_t initval)
      * does it on word boundaries, so is OK with this.  But VALGRIND will
      * still catch it and complain.  The masking trick does make the hash
      * noticably faster for short strings (like English words).
+     * AddressSanitizer is similarly picky about overrunning
+        * the buffer. (http://clang.llvm.org/docs/AddressSanitizer.html
      */
-#ifndef VALGRIND
+#ifdef VALGRIND
+#    define PRECISE_MEMORY_ACCESS 1
+#elif defined(__SANITIZE_ADDRESS__) /* GCC's ASAN */
+#    define PRECISE_MEMORY_ACCESS 1
+#elif defined(__has_feature)
+#  if __has_feature(address_sanitizer) /* Clang's ASAN */
+#    define PRECISE_MEMORY_ACCESS 1
+#  endif
+#endif
+#ifndef PRECISE_MEMORY_ACCESS
 
     switch(length)
     {