When printing sales invoices in CSV format, my error logs are filling up
with errors like the following:

Use of uninitialized value $vars in substitution (s///) at
LedgerSMB/Template/CSV.pm line 78.
Use of uninitialized value $vars in substitution (s///) at
LedgerSMB/Template/CSV.pm line 79.
Use of uninitialized value $vars in pattern match (m//) at
LedgerSMB/Template/CSV.pm line 80.

I am using ledgersmb 1.3.22, with Math::BigInt::GMP.

The errors are triggered inside the LedgerSMB::Template::CSV::preprocess()
function.

For simple scalar values, preprocess() tests and will simply return if the
supplied $rawvars argument is undefined.

But in this case, $rawvars represents a valid Math::BigInt::GMP object,
which passes the defined test. However, when de-referenced, on line 72,
the underlying value of this object is undefined, which causes the pattern
matches to generate warnings.

I propose a small patch that the de-referenced Math::BigInt::GMP is tested
for defined-ness in the same way as the $rawvars argument:


--- /CSV.original.pm    2012-06-17 11:13:17.000000000 +0100
+++ CSV.pm      2012-09-13 07:35:02.415517125 +0100
@@ -68,10 +68,11 @@
                }
        } elsif ( !$type or $type eq 'SCALAR' or $type eq 'Math::BigInt::GMP') {
                        # Scalars or GMP objects (which are SCALAR refs) --CT
                if ($type eq 'SCALAR' or $type eq 'Math::BigInt::GMP') {
                        $vars = $$rawvars;
+                       return unless defined $vars;
                } else {
                        $vars = $rawvars;
                }
                $vars =~ s/(^ +| +$)//g;
                $vars =~ s/"/""/g;





------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ledger-smb-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel

Reply via email to