Skip to content

Commit 8aec797

Browse files
committed
fix WASI
1 parent 5c4009d commit 8aec797

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

Modules/hmacmodule.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -494,14 +494,8 @@ _hacl_hmac_state_update(HACL_HMAC_state *state, uint8_t *buf, Py_ssize_t len)
494494
len -= UINT32_MAX;
495495
}
496496
#endif
497-
if (len > UINT32_MAX_AS_SSIZE_T) {
498-
PyGILState_STATE gstate = PyGILState_Ensure();
499-
PyErr_Format(PyExc_ValueError, "invalid length: %zd (max: %u)",
500-
len, UINT32_MAX);
501-
PyGILState_Release(gstate);
502-
return -1;
503-
}
504-
return _hacl_hmac_state_update_once(state, buf, len);
497+
assert(Py_CHECK_HACL_UINT32_T_LENGTH(len));
498+
return _hacl_hmac_state_update_once(state, buf, (uint32_t)len);
505499
}
506500

507501
/* Static information used to construct the hash table. */
@@ -787,9 +781,13 @@ _hmac_new_impl(PyObject *module, PyObject *keyobj, PyObject *msgobj,
787781
rc = _hacl_hmac_state_update(self->state, msg.buf, msg.len)
788782
);
789783
PyBuffer_Release(&msg);
784+
#ifndef NDEBUG
790785
if (rc < 0) {
791786
goto error;
792787
}
788+
#else
789+
(void)rc;
790+
#endif
793791
}
794792
assert(rc == 0);
795793
PyObject_GC_Track(self);

0 commit comments

Comments
 (0)