Sun May 06 00:32:31 2018: Request 125279 was acted upon.
Transaction: Ticket created by sja...@gmail.com
       Queue: Win32-OLE
     Subject: Use of uninitialized value in OLE.xs Variant::Type() function
   Broken in: (no value)
    Severity: (no value)
       Owner: Nobody
  Requestors: sja...@gmail.com
      Status: new
 Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=125279 >


Hi,

I downloaded the module from CPAN and compiled by myself. The 'make
test' produces some warning messages when performing test on
t/2_variant.t:

% make test
"/usr/bin/perl.exe" -MExtUtils::Command::MM -e 'cp_nonempty' -- OLE.bs
blib/arch/auto/Win32/OLE/OLE.bs 644
PERL_DL_NONLAZY=1 "/usr/bin/perl.exe" "-MExtUtils::Command::MM"
"-MTest::Harness" "-e" "undef *Test::Harness::Switches;
test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/1_nls.t ....... ok
t/2_variant.t ... 1/38 Win32::OLE(0.1712) error 0xffffccb0 at
t/2_variant.t line 39.
        eval {...} called at t/2_variant.t line 39
Win32::OLE(0.1712) error 0xffffccb0 at t/2_variant.t line 40.
        eval {...} called at t/2_variant.t line 40
Win32::OLE(0.1712) error 0xffffccb0 at t/2_variant.t line 73.
        eval {...} called at t/2_variant.t line 73
Win32::OLE(0.1712) error 0xffffccb0 at t/2_variant.t line 94.
        eval {...} called at t/2_variant.t line 94
        :

I found the warning messages come from an issue in OLE.xs function
Type(). There is a flow control according to variable ix and then a
CheckOleError() is called with variable hr. IT seems hr value is
uninitialized on this call if the flow went through ix=0,3,4,5.
A patch to fix it is as attached.

diff -ru Win32-OLE-0.1712-1/OLE.xs Win32-OLE-0.1712-0/OLE.xs
--- Win32-OLE-0.1712-1/OLE.xs	2014-05-15 06:34:17.000000000 +0800
+++ Win32-OLE-0.1712-0/OLE.xs	2018-05-06 12:12:45.264228900 +0800
@@ -5924,7 +5924,7 @@
     SV *sv = &PL_sv_undef;
     if (pVarObj) {
         VARIANT *pVariant = &pVarObj->variant;
-	HRESULT hr;
+	HRESULT hr = 0;
 	HV *olestash = GetWin32OleStash(aTHX_ self);
 	SetLastOleError(aTHX_ olestash);
 	sv = sv_newmortal();

Reply via email to