fix tmpFileName($string) regression introduced in v4.71#278
Merged
leejo merged 1 commit intoMay 5, 2026
Conversation
Commit a1940af changed the .tmpfiles hash key from $$filehandle . $filehandle to $filehandle->filename . $filehandle for uniqueness reasons. That is correct in the "preferred" branch where $filehandle is always a blessed Fh, but the legacy backwards-compat branch iterates multi_param() values, which can be plain strings for non-file params. The pre-change form silently no-op'd via symbolic deref; the new form crashes with Can't locate object method "filename" via package "<value>" whenever a non-file param value happens to equal the string passed to tmpFileName. Add a `next unless ref` guard above the string-equality check to skip non-Fh values. Includes a regression test that fails without the guard and passes with it.
Owner
|
Thanks! v4.72 will be on its way to CPAN shortly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Since v4.71 (commit a1940af, fix for #276),
tmpFileName($string)dies withCan't locate object method "filename" via package "<filename>"whenever any form param has a value exactly equal to the string passed in.Cause
The legacy backwards-compat branch in
tmpFileNameiteratesmulti_paramvalues, which can be plain strings. The string-equality check has norefguard, so a plain string whose value happens to equal$filenamepasses through, and the next line attempts$filehandle->filenameon the string and dies.This was harmless before v4.71 because the lookup expression was
$$filehandle . $filehandle(a symbolic-deref) which silently no-op'd on strings. Commit a1940af changed every site that builds the.tmpfileskey to$filehandle->filename . $filehandlefor uniqueness reasons. Correct in the preferred branch where$filehandleis a blessed Fh, but breaks the legacy branch.Fix
Add
next unless ref($filehandle);above the string-equality check in the legacy branch, restoring the prior behavior of silently no-op'ing on non-Fh values.Test
t/tmpfilename_string_arg.tadds a regression test that fails without the guard (dies intmpFileName) and passes with it.Environment
t/continue to pass.