mirror of https://github.com/akheron/jansson
Merge pull request #180 from Sannis/master
Enable usage of AddressSanitizer to check Jansson
This commit is contained in:
commit
28d362cf28
|
@ -205,7 +205,22 @@ static uint32_t hashlittle(const void *key, size_t length, uint32_t initval)
|
||||||
if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) {
|
if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) {
|
||||||
const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */
|
const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */
|
||||||
|
|
||||||
|
/* Detect Valgrind or AddressSanitizer */
|
||||||
#ifdef VALGRIND
|
#ifdef VALGRIND
|
||||||
|
# define NO_MASKING_TRICK 1
|
||||||
|
#else
|
||||||
|
# if defined(__has_feature) /* Clang */
|
||||||
|
# if __has_feature(address_sanitizer) /* is ASAN enabled? */
|
||||||
|
# define NO_MASKING_TRICK 1
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# if defined(__SANITIZE_ADDRESS__) /* GCC 4.8.x, is ASAN enabled? */
|
||||||
|
# define NO_MASKING_TRICK 1
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NO_MASKING_TRICK
|
||||||
const uint8_t *k8;
|
const uint8_t *k8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -230,7 +245,7 @@ static uint32_t hashlittle(const void *key, size_t length, uint32_t initval)
|
||||||
* still catch it and complain. The masking trick does make the hash
|
* still catch it and complain. The masking trick does make the hash
|
||||||
* noticably faster for short strings (like English words).
|
* noticably faster for short strings (like English words).
|
||||||
*/
|
*/
|
||||||
#ifndef VALGRIND
|
#ifndef NO_MASKING_TRICK
|
||||||
|
|
||||||
switch(length)
|
switch(length)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue