Subject: | Crash in BrowseForFolder() |
Date: | Wed, 29 Mar 2017 16:34:46 +0000 |
To: | "bug-Win32-FileOp [...] rt.cpan.org" <bug-Win32-FileOp [...] rt.cpan.org> |
From: | "Neubauer, Ralf" <ralf.neubauer [...] wido.bv.aok.de> |
Hi,
BrowseForFolder() used to work for a long time, but suddenly it crashes perl after the directory selection dialog is closed. This reproducibly happens for ActivePerl 5.14.2-1402 and for Strawberry 5.24.0.1 (32 bit), for me with Win7-64 and for someone else with Win7-32 in the same network.
I for example call it as:
say BrowseForFolder 'bla', CSIDL_DESKTOP, 0;
If I comment out the CoTaskMemFree() in sub BrowseForFolder, it doesn't crash:
$Win32::FileOp::SHGetSpecialFolderLocation->Call($hwndOwner, $nFolder, $pidlRoot)
and return;
/* ... other code ... */
$pszPath =~ s/\0.*$//s;
# Memory leak, but no crash.
# $Win32::FileOp::CoTaskMemFree->Call($pidlRoot);
$bool ? $pszPath : undef;
If I comment out the SHBrowseForFolder() it also doesn't crash, but this is not very useful:
my $bool = 0 && $Win32::FileOp::SHGetPathFromIDList->Call(
$Win32::FileOp::SHBrowseForFolder->Call($browseinfo),
$pszPath
);
$pszPath =~ s/\0.*$//s;
$Win32::FileOp::CoTaskMemFree->Call($pidlRoot);
Just commenting out SHGetPathFromIDList() still crashes, so the bug may well be in the setup of $browseinfo:
$Win32::FileOp::SHGetSpecialFolderLocation->Call($hwndOwner, $nFolder, $pidlRoot)
and return;
my $pidlRootUnpacked = hex unpack 'H*',(join'', reverse split//, $pidlRoot);
my $browseinfo = pack 'LLppILLI',
($hwndOwner, $pidlRootUnpacked, $pszDisplayName, $lpszTitle,
$ulFlags, $lpfn, $lParam, $iImage);
my $folder = $Win32::FileOp::SHBrowseForFolder->Call($browseinfo);
my $bool = 0 && $Win32::FileOp::SHGetPathFromIDList->Call(
$folder, $pszPath
);
$pszPath =~ s/\0.*$//s;
$Win32::FileOp::CoTaskMemFree->Call($pidlRoot);
Ralf