Skip to content

Commit f20b01b

Browse files
Marcel Plchencukou
Marcel Plch
authored andcommitted
Initialize HMAC type.
1 parent 0a1522a commit f20b01b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Modules/_hmacopenssl.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
#include "_hashopenssl.h"
2323

2424

25-
#include <openssl/hmac.h>
2625

2726
typedef struct hmacopenssl_state {
2827
PyTypeObject *HmacType;
2928
} hmacopenssl_state;
3029

30+
#include <openssl/hmac.h>
3131

3232
typedef struct {
3333
PyObject_HEAD
@@ -39,7 +39,7 @@ typedef struct {
3939
#include "clinic/_hmacopenssl.c.h"
4040
/*[clinic input]
4141
module _hmacopenssl
42-
class _hmacopenssl.HMAC "HmacObject *" "PyModule_GetState(module)->HmacType"
42+
class _hmacopenssl.HMAC "HmacObject *" "((hmacopenssl_state *)PyModule_GetState(module))->HmacType"
4343
[clinic start generated code]*/
4444
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=204b7f45847f57b4]*/
4545

@@ -71,7 +71,7 @@ _hmacopenssl_new_impl(PyObject *module, Py_buffer *key,
7171
return NULL;
7272
}
7373

74-
/* name mut be lowercase */
74+
/* name must be lowercase */
7575
for (int i=0; digestmod[i]; i++) {
7676
if (
7777
((digestmod[i] < 'a') || (digestmod[i] > 'z'))
@@ -383,7 +383,8 @@ hmacopenssl_exec(PyObject *m) {
383383
* on what hashes are supported rather than listing many
384384
* and having some unsupported. Only init appropriate
385385
* constants. */
386-
PyObject *temp;
386+
PyObject *temp = NULL;
387+
hmacopenssl_state *state;
387388

388389
temp = PyType_FromSpec(&HmacType_spec);
389390
if (temp == NULL) {
@@ -394,6 +395,9 @@ hmacopenssl_exec(PyObject *m) {
394395
goto fail;
395396
}
396397

398+
state = PyModule_GetState(m);
399+
state->HmacType = (PyTypeObject *)temp;
400+
397401
return 0;
398402

399403
fail:

0 commit comments

Comments
 (0)