Skip to content

Commit f350501

Browse files
committed
GIL protection
1 parent 417cee1 commit f350501

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

Modules/hmacmodule.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -390,39 +390,36 @@ narrow_hmac_hash_kind(hmacmodule_state *state, HMAC_Hash_Kind kind)
390390
static int
391391
_hacl_convert_errno(hacl_errno_t code)
392392
{
393-
int res = -1;
393+
if (code == Hacl_Streaming_Types_Success) {
394+
return 0;
395+
}
394396
PyGILState_STATE gstate = PyGILState_Ensure();
395397
switch (code) {
396-
case Hacl_Streaming_Types_Success: {
397-
res = 0;
398-
goto finally;
399-
}
400398
case Hacl_Streaming_Types_InvalidAlgorithm: {
401399
PyErr_SetString(PyExc_ValueError, "invalid HACL* algorithm");
402-
goto finally;
400+
break;
403401
}
404402
case Hacl_Streaming_Types_InvalidLength: {
405403
PyErr_SetString(PyExc_ValueError, "invalid length");
406-
goto finally;
404+
break;
407405
}
408406
case Hacl_Streaming_Types_MaximumLengthExceeded: {
409407
PyErr_SetString(PyExc_OverflowError, "maximum length exceeded");
410-
goto finally;
408+
break;
411409
}
412410
case Hacl_Streaming_Types_OutOfMemory: {
413411
PyErr_NoMemory();
414-
goto finally;
412+
break;
415413
}
416414
default: {
417415
PyErr_Format(PyExc_RuntimeError,
418416
"HACL* internal routine failed with error code: %d",
419417
code);
420-
goto finally;
418+
break;
421419
}
422420
}
423-
finally:
424421
PyGILState_Release(gstate);
425-
return res;
422+
return -1;
426423
}
427424

428425
/*

0 commit comments

Comments
 (0)