]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
lei_saved_search: avoid //= on complex hashref assignment
authorEric Wong <e@80x24.org>
Tue, 26 Aug 2025 19:50:43 +0000 (19:50 +0000)
committerEric Wong <e@80x24.org>
Thu, 28 Aug 2025 18:48:14 +0000 (18:48 +0000)
Setting $self->{oidx} via `//=' may be unsafe due to
->lock_for_scope setting $self->{lock_fh}.  While this is not
known to cause problems at the moment, it may be problematic in
future as we've had to deal with subtle bugs in similar code in
the past.

lib/PublicInbox/LeiSavedSearch.pm

index aed8b0c9c4fa00aeb2d951e446da9322c4414c4b..3361f758a8618c7b8084b48926e51fafa201354a 100644 (file)
@@ -229,7 +229,7 @@ sub is_dup {
 
 sub prepare_dedupe {
        my ($self) = @_;
-       $self->{oidx} //= do {
+       $self->{oidx} // do {
                my $creat = !-f $self->{-ovf};
                my $lk = $self->lock_for_scope; # git-config doesn't wait
                my $oidx = PublicInbox::OverIdx->new($self->{-ovf});
@@ -237,7 +237,7 @@ sub prepare_dedupe {
                $oidx->{journal_mode} = 'WAL';
                $oidx->dbh;
                $oidx->eidx_prep if $creat; # for xref3
-               $oidx
+               $self->{oidx} = $oidx
        };
 }