File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -509,14 +509,19 @@ _sha3_shake_128_digest_impl(SHA3object *self, Py_ssize_t length)
509509 if (length == 0 ) {
510510 return Py_GetConstant (Py_CONSTANT_EMPTY_BYTES );
511511 }
512-
513512 CHECK_HACL_UINT32_T_LENGTH (length );
514- PyObject * digest = PyBytes_FromStringAndSize (NULL , length );
515- uint8_t * buffer = (uint8_t * )PyBytes_AS_STRING (digest );
513+
514+ PyBytesWriter * writer = PyBytesWriter_Create (length );
515+ if (writer == NULL ) {
516+ return NULL ;
517+ }
518+ uint8_t * buffer = (uint8_t * )PyBytesWriter_GetData (writer );
519+
516520 HASHLIB_ACQUIRE_LOCK (self );
517521 (void )Hacl_Hash_SHA3_squeeze (self -> hash_state , buffer , (uint32_t )length );
518522 HASHLIB_RELEASE_LOCK (self );
519- return digest ;
523+
524+ return PyBytesWriter_Finish (writer );
520525}
521526
522527
You can’t perform that action at this time.
0 commit comments