CC: | Jean McAllister <Jean.Mcallister [...] infor.com>, Mark Hewitt <Mark.Hewitt [...] infor.com> |
Subject: | Win32::TieRegistry::ValueNames error with Strawberry Perl 5.20 |
Date: | Wed, 29 Oct 2014 18:40:16 +0000 |
To: | "bug-Win32-TieRegistry [...] rt.cpan.org" <bug-Win32-TieRegistry [...] rt.cpan.org> |
From: | Bruce Reed <Bruce.Reed [...] infor.com> |
This is in Version 0.26 of Win32::TieRegistry.
There are actually two issues here.
Issue #1
ValueNames calls _enumValues.
If _enumValues does not set $self->{VALUES} for any reason, it remains an undefined value.
Then ValueNames still tries to use as an Array reference it at line 682 without checking if it's set.
Issue #2 - this is the real problem
_enumValues is making this call to a Win32API::Registry function:
my $nlen= 1+$self->Information("MaxValNameLen");
while( $self->RegEnumValue($pos++,$name,$nlen,[],[],[],[]) ) {
According to the documentation for Win32API::Registry:
$plValName initially specifies the [minimum] buffer size to be allocated for $sValName. Will be set to the length of the value name if the requested value exists even if $sValName isn't successfully set to the value name. See "Buffer sizes" for more information.
"$plValName" is $nlen in this function call.
$nlen is getting changed by the call to RegEnumValue, but is not getting reset to the MaxValNameLen value (plus 1) for the next call to RegEnumValue.
This works OK with ActivePerl 5.18 and Strawberry Perl 5.18, and I assume earlier versions of both.
However, it fails with Strawberry Perl 5.20 with this message:
Can't use an undefined value as an ARRAY reference at c:/Strawberry64/perl/vendor/lib/Win32/TieRegistry.pm line 682.
In my testing, if I reset $nlen to the value taken from MaxValNameLen, or just pass null (undef) instead of $nlen, it works OK even with Strawberry Perl 5.20.
[cid:image001.png@01CFEC4C.24180FA0]
Bruce Reed | Lead Software Engineer - Systems
office/mobile: 989 430 2897 | urgent: 9894302897@vtext.com<mailto:9894302897@vtext.com> | bruce.reed@infor.com<mailto:bruce.reed@infor.com> | http://www.infor.com