File: properly_delete_elements_of_tied_hash.patch

package info (click to toggle)
spamassassin 4.0.1-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 22,960 kB
  • sloc: perl: 86,207; ansic: 5,193; sh: 3,710; javascript: 339; sql: 279; makefile: 209; python: 49
file content (22 lines) | stat: -rw-r--r-- 941 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Description: properly delete elements of tied hash
Origin: upstream
Bug: https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8237
Index: sid/lib/Mail/SpamAssassin/DBBasedAddrList.pm
===================================================================
--- sid.orig/lib/Mail/SpamAssassin/DBBasedAddrList.pm
+++ sid/lib/Mail/SpamAssassin/DBBasedAddrList.pm
@@ -165,11 +165,10 @@ sub remove_entry {
     # could be slow...
     my $mailaddr = $1;
 
-    while (my ($key, $value) = each %{$self->{accum}}) {
-      # regex will catch both key and key|totscore entries and delete them
-      if ($key =~ /^\Q${mailaddr}\E\|/) {
+    # regex will catch both key and key|totscore entries and delete them
+    # bug 8237 - Never use while my ($key, $value) (each %hash) to delete elements when using tied hashes
+    foreach my $key (grep {/^\Q${mailaddr}\E\|/} keys %{$self->{accum}}) {
         delete $self->{accum}->{$key};
-      }
     }
   }
 }