krb5 commit: Handle missing autocomplete object gracefully

Benjamin Kaduk kaduk at MIT.EDU
Wed Aug 29 14:55:53 EDT 2012


https://github.com/krb5/krb5/commit/c6753181c2e59316c40fe0f6d1a55df542401c51
commit c6753181c2e59316c40fe0f6d1a55df542401c51
Author: Kevin Wasserman <kevin.wasserman at painless-security.com>
Date:   Thu Jul 26 21:08:14 2012 -0400

    Handle missing autocomplete object gracefully
    
    Don't crash if we can't create a CLSID_AutoComplete instance.
    
    Signed-off-by: Kevin Wasserman <kevin.wasserman at painless-security.com>
    
    ticket: 7321 (new)
    queue: kfw
    target_version: 1.10.4
    tags: pullup

 src/windows/leashdll/lshutil.cpp |   29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/windows/leashdll/lshutil.cpp b/src/windows/leashdll/lshutil.cpp
index 32dab58..37c0723 100644
--- a/src/windows/leashdll/lshutil.cpp
+++ b/src/windows/leashdll/lshutil.cpp
@@ -440,7 +440,8 @@ protected:
                 }
                 // add the new one
                 m_enumString->AddString(princStr);
-                m_acdd->ResetEnumerator();
+                if (m_acdd != NULL)
+                    m_acdd->ResetEnumerator();
                 m_princStr = princStr;
             }
         }
@@ -524,25 +525,25 @@ protected:
         IAutoComplete *pac = NULL;
         hRes = CoCreateInstance(CLSID_AutoComplete, NULL, CLSCTX_INPROC_SERVER,
                                 IID_PPV_ARGS(&pac));
-        // @TODO: error handling
+        if (pac != NULL) {
+            pac->Init(m_hwnd, pEnumString, NULL, NULL);
 
-        pac->Init(m_hwnd, pEnumString, NULL, NULL);
-
-        IAutoCompleteDropDown* pacdd = NULL;
-        hRes = pac->QueryInterface(IID_IAutoCompleteDropDown, (LPVOID*)&pacdd);
-        pac->Release();
+            IAutoCompleteDropDown* pacdd = NULL;
+            hRes = pac->QueryInterface(IID_IAutoCompleteDropDown, (LPVOID*)&pacdd);
+            pac->Release();
 
         // @TODO: auto-suggest; other advanced options?
 #if 0
-        IAutoComplete2 *pac2;
+            IAutoComplete2 *pac2;
 
-        if (SUCCEEDED(pac->QueryInterface(IID_IAutoComplete2, (LPVOID*)&pac2)))
-        {
-            pac2->SetOptions(ACO_AUTOSUGGEST);
-            pac2->Release();
-        }
+            if (SUCCEEDED(pac->QueryInterface(IID_IAutoComplete2,
+                                              (LPVOID*)&pac2))) {
+                pac2->SetOptions(ACO_AUTOSUGGEST);
+                pac2->Release();
+            }
 #endif
-        m_acdd = pacdd;
+            m_acdd = pacdd;
+        }
     }
 
     void DestroyAutocomplete()


More information about the cvs-krb5 mailing list