Skip Menu |

This queue is for tickets about the Image-ExifTool CPAN distribution.

Report information
The Basics
Id: 47248
Status: resolved
Priority: 0/
Queue: Image-ExifTool

People
Owner: Nobody in particular
Requestors: JBERT [...] cpan.org
Cc: john [...] humyo.com
AdminCc:

Bug Information
Severity: Normal
Broken in: 7.67
Fixed in: 7.82



CC: john [...] humyo.com
Subject: error conditions can leave $/ changed
Hi, I'm afraid that I don't have a concrete failure case to hand, but at least one of the Image/ExifTool handlers (Postscript.pm) sets the input record seperator ($/) and doesn't set it back to the old value in some cases. We do see this problem on our live data. We typically call ->ExtractInfo on a filehandle and so, with no file extension, exiftool has to run through a list of possible handler, which probably means we hit more error paths. Here is one potentially problematic snippet: my $oldsep = SetInputRecordSeparator($raf); $oldsep or return PSErr($exifTool, 'invalid PS data'); # set file type (PostScript or EPS) $raf->ReadLine($data) or return 0; $exifTool->SetFileType($data =~ /EPSF/ ? 'EPS' : 'PS'); if we take the 'return 0' error return we'll have left $/ set to whatever SetInputRecordSeparator decided. Some suggested fixes: - never assign to $/ with a 'local' qualifier. You could do this reasonably cleanly by changing SetInputRecordSeperator to 'chooseInputRecordSeperator' (return the desired seperator) and writing code like this: local $/ = ChooseInputRecordSeperator($raf); the localisation will then take care of everything. - have top-level 'local $/ = $/' at the entry points into your module, to ensure we get back the value of $/ we entered with. Thanks for the great module, hope this feedback helps.
Hi John, Thanks for this useful tip. I will localise $/ for the next release (version 7.80). - Phil
Oh, On Mon Jun 22 13:14:38 2009, JBERT wrote: Show quoted text
> - never assign to $/ with a 'local' qualifier.
I assume you meant "without a 'local' qualifier, as per your example?: Show quoted text
> local $/ = ChooseInputRecordSeperator($raf);
This is what I will do. - Phil
On Mon Jun 22 19:45:13 2009, EXIFTOOL wrote: Show quoted text
> Oh, > > On Mon Jun 22 13:14:38 2009, JBERT wrote:
> > - never assign to $/ with a 'local' qualifier.
> > I assume you meant "without a 'local' qualifier, as per your example?:
Yes, you're right, sorry for that. Show quoted text
> > local $/ = ChooseInputRecordSeperator($raf);
> > This is what I will do.
Cool, thanks. jb