File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ static PyTypeObject EVPtype;
7070
7171
7272#define DEFINE_CONSTS_FOR_NEW (Name ) \
73- static PyObject *CONST_ ## Name ## _name_obj; \
73+ static PyObject *CONST_ ## Name ## _name_obj = NULL ; \
7474 static EVP_MD_CTX CONST_new_ ## Name ## _ctx; \
7575 static EVP_MD_CTX *CONST_new_ ## Name ## _ctx_p = NULL;
7676
@@ -585,12 +585,15 @@ generate_hash_name_list(void)
585585 " hash object; optionally initialized with a string") \
586586 }
587587
588- /* used in the init function to setup a constructor */
588+ /* used in the init function to setup a constructor: initialize OpenSSL
589+ constructor constants if they haven't been initialized already. */
589590#define INIT_CONSTRUCTOR_CONSTANTS (NAME ) do { \
590- CONST_ ## NAME ## _name_obj = PyUnicode_FromString(#NAME); \
591- if (EVP_get_digestbyname(#NAME)) { \
592- CONST_new_ ## NAME ## _ctx_p = &CONST_new_ ## NAME ## _ctx; \
593- EVP_DigestInit(CONST_new_ ## NAME ## _ctx_p, EVP_get_digestbyname(#NAME)); \
591+ if (CONST_ ## NAME ## _name_obj == NULL) { \
592+ CONST_ ## NAME ## _name_obj = PyUnicode_FromString(#NAME); \
593+ if (EVP_get_digestbyname(#NAME)) { \
594+ CONST_new_ ## NAME ## _ctx_p = &CONST_new_ ## NAME ## _ctx; \
595+ EVP_DigestInit(CONST_new_ ## NAME ## _ctx_p, EVP_get_digestbyname(#NAME)); \
596+ } \
594597 } \
595598} while (0);
596599
You can’t perform that action at this time.
0 commit comments