Subject: | Win32::API::Call: parameter X had a buffer overflow with UTF-8 strings |
Date: | Wed, 30 Nov 2016 22:37:21 +0200 |
To: | bug-Win32-API [...] rt.cpan.org |
From: | Mikko Noromaa <mikko [...] noromaa.fi> |
Hello,
use strict;
use Win32::API;
use Encode;
my $data = Encode::decode('UTF-8',"The price is \xe2\x82\xac5.");
my $WriteFile = Win32::API->new('kernel32.dll', 'WriteFile', 'IPIPI', 'i')
or die "Unable to load WriteFile: $!";
my $written = " " x 4;
$WriteFile->Call(0, $data, 4, $written, 0);
This fails with:
Win32::API::Call: parameter 2 had a buffer overflow
Tested on ActiveState Perl v. 5.22.1 and 5.18.2, Win::API versions 0.84,
0.82 and 0.75. Same problem happened on all of them.
--
Mikko Noromaa (mikko@noromaa.fi) - tel. +358 40 7348034