Skip to content

Commit

Permalink
fix "uninitialized value" warnings for readline()
Browse files Browse the repository at this point in the history
Like getc or (sys)read, readline can return undef even if its argument
is fully defined.
  • Loading branch information
mauke committed Feb 7, 2024
1 parent b9a5b9e commit 34c5e5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions sv.c
Original file line number Diff line number Diff line change
Expand Up @@ -17408,6 +17408,7 @@ S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv,
case OP_TIED:
case OP_GETC:
case OP_SYSREAD:
case OP_READLINE:
case OP_SEND:
case OP_IOCTL:
case OP_SOCKET:
Expand Down
7 changes: 7 additions & 0 deletions t/lib/warnings/9uninit
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,13 @@ Use of uninitialized value in addition (+) at - line 4.
use warnings 'uninitialized';
my $nofile = '/no/such/file';
my $v;
$v = 1 + readline($nofile);
EXPECT
Use of uninitialized value in addition (+) at - line 4.
########
use warnings 'uninitialized';
my $nofile = '/no/such/file';
my $v;
$v = 1 + eval { send($nofile, $buf,0) };
EXPECT
Use of uninitialized value in addition (+) at - line 4.
Expand Down

0 comments on commit 34c5e5b

Please sign in to comment.