summaryrefslogtreecommitdiffstats
path: root/extensions/source/scanner/twain32shim.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/source/scanner/twain32shim.cxx')
-rw-r--r--extensions/source/scanner/twain32shim.cxx7
1 files changed, 4 insertions, 3 deletions
diff --git a/extensions/source/scanner/twain32shim.cxx b/extensions/source/scanner/twain32shim.cxx
index beca35f4f26b..5827a946fedb 100644
--- a/extensions/source/scanner/twain32shim.cxx
+++ b/extensions/source/scanner/twain32shim.cxx
@@ -28,6 +28,7 @@
*/
#include "twain32shim.hxx"
+#include <systools/win32/comtools.hxx>
#include <tools/helpers.hxx>
#include <twain/twain.h>
#include <o3tl/unit_conversion.hxx>
@@ -251,11 +252,10 @@ void ImpTwain::ImplOpenSourceManager()
if (!m_hMod)
{
// Windows directory might not be in DLL search path sometimes, so try the full path
- PWSTR sPath;
+ sal::systools::CoTaskMemAllocated<wchar_t> sPath;
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Windows, 0, nullptr, &sPath)))
{
- std::wstring sPathAndFile = sPath;
- CoTaskMemFree(sPath);
+ std::wstring sPathAndFile(sPath);
sPathAndFile += L"\\TWAIN_32.DLL";
m_hMod = LoadLibraryW(sPathAndFile.c_str());
}
@@ -287,6 +287,7 @@ void ImpTwain::ImplOpenSource()
TW_CAPABILITY aCap
= { CAP_XFERCOUNT, TWON_ONEVALUE, GlobalAlloc(GHND, sizeof(TW_ONEVALUE)) };
TW_ONEVALUE* pVal = static_cast<TW_ONEVALUE*>(GlobalLock(aCap.hContainer));
+ assert(pVal);
pVal->ItemType = TWTY_INT16;
pVal->Item = 1;