From a4b9c3624221bb7e1ec6d575d673e2d770704f54 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 26 Sep 2016 11:11:10 +0200 Subject: [PATCH] Over-paranoid Debug Alert with empty certificate list resolved - The "" certificate on the list of certificates has now wxCertificateClientData of NULL to declare wxChoice will use client object data; - wxChoice selection index and availability of client object data are now verified before wxChoice::GetClientObject() call is made (closes #21) --- lib/TLS_UI/src/TLS_UI.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/TLS_UI/src/TLS_UI.cpp b/lib/TLS_UI/src/TLS_UI.cpp index edfbee5..5aa2639 100644 --- a/lib/TLS_UI/src/TLS_UI.cpp +++ b/lib/TLS_UI/src/TLS_UI.cpp @@ -324,7 +324,7 @@ wxTLSCredentialsPanel::wxTLSCredentialsPanel(const eap::config_provider &prov, c bool wxTLSCredentialsPanel::TransferDataToWindow() { // Populate certificate list. - m_certificate->Append(_("")); + m_certificate->Append(_(""), (wxCertificateClientData*)NULL); bool is_found = false; winstd::cert_store store; if (store.create(CERT_STORE_PROV_SYSTEM, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, (HCRYPTPROV)NULL, CERT_SYSTEM_STORE_CURRENT_USER, _T("My"))) { @@ -363,7 +363,12 @@ bool wxTLSCredentialsPanel::TransferDataToWindow() bool wxTLSCredentialsPanel::TransferDataFromWindow() { - const wxCertificateClientData *data = dynamic_cast(m_certificate->GetClientObject(m_certificate->GetSelection())); + // Check if m_certificate control has selected item, and has client object data (at least one user certificate on the list). Then try to get the data from selected item. + int sel = m_certificate->GetSelection(); + const wxCertificateClientData *data = + sel != wxNOT_FOUND && m_certificate->HasClientObjectData() ? + dynamic_cast(m_certificate->GetClientObject(sel)) : + NULL; if (data) m_cred.m_cert.attach_duplicated(data->m_cert); else