Skip to content

Commit 6282125

Browse files
authored
Fix #2636 - mark PyCERT_CONTEXT as freed after a call to CertDeleteCertificateFromStore (#2637)
1 parent 0c7297b commit 6282125

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

win32/src/win32crypt/PyCERT_CONTEXT.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ PyObject *PyCERT_CONTEXT::PyCertDeleteCertificateFromStore(PyObject *self, PyObj
418418
GET_CERT_CONTEXT(pcert_context);
419419
BOOL bsuccess;
420420
Py_BEGIN_ALLOW_THREADS bsuccess = CertDeleteCertificateFromStore(pcert_context);
421+
// CertDeleteCertificateFromStore internally calls CertFreeCertificateContext, so we need to zero
422+
// the context like we do in PyCertFreeCertificateContext, in order to prevent an attempt to free
423+
// it again later in the destructor.
424+
((PyCERT_CONTEXT *)self)->pccert_context = NULL;
421425
Py_END_ALLOW_THREADS if (!bsuccess) return PyWin_SetAPIError("CertDeleteCertificateFromStore");
422426
Py_INCREF(Py_None);
423427
return Py_None;

0 commit comments

Comments
 (0)