https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7164

--- Comment #2 from Simon Matter <[email protected]> ---
###########################################################################
sub check_reputation {
###########################################################################
  my ($self, $storage, $pms, $key, $id, $ip, $signedby, $msgscore) = @_;

  my $delta  = 0;
  my $weight = ($key eq 'MSG_ID')? 1 :
eval('$pms->{main}->{conf}->{txrep_weight_'.lc($key).'}');

  if (defined $weight && $weight) {
    my $meanrep;
    my $timer = $self->{main}->time_method('check_txrep_'.lc($key));

    if (defined $storage) {
        $self->{checker} = $self->{$storage};
    }
    my $found  = $self->get_sender($id, $ip, $signedby);
    my $tag_id = (defined $storage)? uc($key.'_'.substr($storage,0,1)) :
uc($key);
    if (defined $found && $self->count()) {
        $meanrep = $self->total() / $self->count();
    }
    if ($self->{learning} && defined $msgscore) {
        if (defined $meanrep) {
            # $msgscore<=>0 gives the sign of $msgscore
            $msgscore += ($msgscore<=>0) * abs($meanrep);
        }
        dbg("TxRep: reputation: %s, count: %d, learning: %s, $tag_id: %s",
            defined $meanrep? sprintf("%.3f",$meanrep) : 'none',
            $self->count()      || 0,
            $self->{learning}   || '',
            $id                 || 'none'
        );
    } else {
        $self->{totalweight} += $weight;
        if ($key eq 'MSG_ID' && $self->count() > 0) {
            $delta = $self->total() / $self->count();
            $pms->set_tag('TXREP'.$tag_id,             
sprintf("%2.1f",$delta));
        } elsif (defined $self->total()) {
            $delta = ($self->total() + $msgscore) / (1 + $self->count()) -
$msgscore;

Here the error happens. Sorry for not really knowing perl but, from what I see,
if check_reputation is called with undefined msgscore, it's possible to end up
in the line above without defining it before. Isn't that what produces the
error?

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to