Skip Menu |

This queue is for tickets about the JSON CPAN distribution.

Report information
The Basics
Id: 19059
Status: resolved
Priority: 0/
Queue: JSON

People
Owner: Nobody in particular
Requestors: philip.tellis [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.05
Fixed in: (no value)



Subject: Parser.pm throws warnings when $ch has undef value
Parser.pm iterates over $ch and does many checks for numeric, string, etc. It does not check if $ch is undef after every increment, and this causes warnings to be thrown into the error logs. The attached file is a patch to fix the problem. I'm using perl 5.6.2 and $JSON::VERSION=1.05
Subject: JSON-Parser.pm.diff
--- JSON/Parser.pm Mon Mar 13 23:21:54 2006 +++ JSON/Parser.pm Tue Mar 21 17:08:57 2006 @@ -236,7 +236,7 @@ my $n = ''; my $v; - if($ch eq '0'){ + if(defined $ch && $ch eq '0'){ my $peek = substr($text,$at,1); my $hex = $peek =~ /[xX]/; @@ -254,24 +254,24 @@ } } - if($ch eq '-'){ + if(defined $ch && $ch eq '-'){ $n = '-'; next_chr; } - while($ch =~ /\d/){ + while(defined $ch && $ch =~ /\d/){ $n .= $ch; next_chr; } - if($ch eq '.'){ + if(defined $ch && $ch eq '.'){ $n .= '.'; while(defined(next_chr) and $ch =~ /\d/){ $n .= $ch; } } - if($ch eq 'e' or $ch eq 'E'){ + if(defined $ch and ($ch eq 'e' or $ch eq 'E')){ $n .= $ch; next_chr;
Thanks for your report and sorry that the answer is late. Well, I did not expect that such warning went out. Could you send the sample code where the problem is caused?
The above comment was me.
From: Philip
I can't seem to reproduce right now even after reverting to the old code.