We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f7d0d06 commit b389f01Copy full SHA for b389f01
src/core/value.c
@@ -322,7 +322,8 @@ int32_t janet_hash(Janet x) {
322
break;
323
case JANET_TUPLE:
324
hash = janet_tuple_hash(janet_unwrap_tuple(x));
325
- hash += (janet_tuple_flag(janet_unwrap_tuple(x)) & JANET_TUPLE_FLAG_BRACKETCTOR) ? 1 : 0;
+ uint32_t inc = (janet_tuple_flag(janet_unwrap_tuple(x)) & JANET_TUPLE_FLAG_BRACKETCTOR) ? 1 : 0;
326
+ hash = (int32_t)((uint32_t)hash + inc); /* avoid overflow undefined behavior */
327
328
case JANET_STRUCT:
329
hash = janet_struct_hash(janet_unwrap_struct(x));
0 commit comments