Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 0c679023a9d1d791b7ab05a0ec3952be0f8968e3
      
https://github.com/Perl/perl5/commit/0c679023a9d1d791b7ab05a0ec3952be0f8968e3
  Author: Lukas Mai <[email protected]>
  Date:   2024-02-10 (Sat, 10 Feb 2024)

  Changed paths:
    M sv.c
    M t/lib/warnings/9uninit

  Log Message:
  -----------
  fix "uninitialized value" warnings for shift()/pop()

This fixes an oversight introduced in 1b0ae12.

The Perl code "shift" (or "shift()") produces different optrees
depending on where it occurs: At file scope, it shifts @ARGV and the
corresponding OP has an explicit @ARGV child. But at subroutine scope,
it shifts @_, and @_ is not represented explicitly in the optree.
Instead the parser just generates an OP_SHIFT without any children.

This latter case was not handled in S_find_uninit_var (and blindly
accessing a non-existent child OP would crash perl). pop() was similarly
affected.

Fix: Explicitly check whether OPf_KIDS is set on the OP before accessing
the op_first field (plus some tests for this case).

Fixes #21960.


Reply via email to