Skip to content

Commit e93e046

Browse files
Copilotxusheng6
andcommitted
Fix VARIANT conversion errors in install_windbg.cpp
Co-authored-by: xusheng6 <94503187+xusheng6@users.noreply.github.com>
1 parent beda494 commit e93e046

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

core/adapters/dbgeng/install_windbg.cpp

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,24 @@ namespace BinaryNinjaDebugger
118118
return false;
119119
}
120120

121-
// Convert paths to BSTRs
121+
// Convert paths to BSTRs and then to VARIANTs
122122
_bstr_t bstrZipPath(zipPath.c_str());
123123
_bstr_t bstrExtractPath(extractPath.c_str());
124124

125+
VARIANT vZipPath, vExtractPath;
126+
vZipPath.vt = VT_BSTR;
127+
vZipPath.bstrVal = bstrZipPath.Detach();
128+
vExtractPath.vt = VT_BSTR;
129+
vExtractPath.bstrVal = bstrExtractPath.Detach();
130+
125131
// Get folder objects
126132
Folder* pZipFolder = nullptr;
127133
Folder* pDestFolder = nullptr;
128134

129-
hr = pShellApp->NameSpace(bstrZipPath, &pZipFolder);
135+
hr = pShellApp->NameSpace(vZipPath, &pZipFolder);
130136
if (SUCCEEDED(hr) && pZipFolder)
131137
{
132-
hr = pShellApp->NameSpace(bstrExtractPath, &pDestFolder);
138+
hr = pShellApp->NameSpace(vExtractPath, &pDestFolder);
133139
if (SUCCEEDED(hr) && pDestFolder)
134140
{
135141
// Get items from zip folder
@@ -174,6 +180,10 @@ namespace BinaryNinjaDebugger
174180
LogError("Failed to open zip file as folder: 0x%08x", hr);
175181
}
176182

183+
// Clean up VARIANTs
184+
VariantClear(&vZipPath);
185+
VariantClear(&vExtractPath);
186+
177187
pShellApp->Release();
178188
}
179189
catch (...)
@@ -224,18 +234,24 @@ namespace BinaryNinjaDebugger
224234
return "";
225235
}
226236

227-
// Convert paths to BSTRs
237+
// Convert paths to BSTRs and then to VARIANTs
228238
_bstr_t bstrZipPath(zipPath.c_str());
229239
_bstr_t bstrExtractPath(extractDir.c_str());
230240

241+
VARIANT vZipPath, vExtractPath;
242+
vZipPath.vt = VT_BSTR;
243+
vZipPath.bstrVal = bstrZipPath.Detach();
244+
vExtractPath.vt = VT_BSTR;
245+
vExtractPath.bstrVal = bstrExtractPath.Detach();
246+
231247
// Get folder objects
232248
Folder* pZipFolder = nullptr;
233249
Folder* pDestFolder = nullptr;
234250

235-
hr = pShellApp->NameSpace(bstrZipPath, &pZipFolder);
251+
hr = pShellApp->NameSpace(vZipPath, &pZipFolder);
236252
if (SUCCEEDED(hr) && pZipFolder)
237253
{
238-
hr = pShellApp->NameSpace(bstrExtractPath, &pDestFolder);
254+
hr = pShellApp->NameSpace(vExtractPath, &pDestFolder);
239255
if (SUCCEEDED(hr) && pDestFolder)
240256
{
241257
// Get items from zip folder
@@ -316,6 +332,10 @@ namespace BinaryNinjaDebugger
316332
LogError("Failed to open zip file as folder: 0x%08x", hr);
317333
}
318334

335+
// Clean up VARIANTs
336+
VariantClear(&vZipPath);
337+
VariantClear(&vExtractPath);
338+
319339
pShellApp->Release();
320340
}
321341
catch (...)

0 commit comments

Comments
 (0)