Skip to content

Commit

Permalink
Clear or don't check $@ in cases where eval is not called
Browse files Browse the repository at this point in the history
The contents of $@ are unknown if eval isn't run, so we can't rely on it
unless we set it ourselves.
  • Loading branch information
jonjensen committed Nov 2, 2017
1 parent 77653a2 commit 9bba0b5
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 24 deletions.
14 changes: 6 additions & 8 deletions lib/Vend/Config.pm
Expand Up @@ -54,7 +54,7 @@ use Vend::Data;
use Vend::Cron;
use Vend::CharSet ();

$VERSION = '2.249';
$VERSION = '2.250';

my %CDname;
my %CPname;
Expand Down Expand Up @@ -787,10 +787,8 @@ sub global_chunk {
eval {
$GlobalRead->($lvar, $value);
};
if($@ =~ /Duplicate\s+usertag/i) {
next;
}
if($@) {
if ($@) {
next if $@ =~ /Duplicate\s+usertag/i;
::logDebug("error running global $lvar: $@");
}
}
Expand Down Expand Up @@ -865,9 +863,7 @@ sub code_from_file {
eval {
$GlobalRead->($lvar, $value);
};
if($@ =~ /Duplicate\s+usertag/i) {
next;
}
next if $@ =~ /Duplicate\s+usertag/i;
}
close SYSTAG;
close NEWTAG;
Expand Down Expand Up @@ -2201,6 +2197,8 @@ sub parse_action {
$sub =~ s/^\s*((?s:.)*\S)\s*//;
$sub = $1;

# clear errors for code paths below that don't call eval or reval
undef $@;
if($sub !~ /\s/) {
no strict 'refs';
if($sub =~ /::/ and ! $C) {
Expand Down
9 changes: 5 additions & 4 deletions lib/Vend/DbSearch.pm
Expand Up @@ -2,7 +2,7 @@
#
# Adapted for use with Interchange from Search::TextSearch
#
# Copyright (C) 2002-2007 Interchange Development Group
# Copyright (C) 2002-2017 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
Expand All @@ -25,7 +25,7 @@ require Vend::Search;

@ISA = qw(Vend::Search);

$VERSION = substr(q$Revision: 2.27 $, 10);
$VERSION = '2.28';

use Search::Dict;
use strict;
Expand Down Expand Up @@ -198,7 +198,9 @@ sub search {
if ($s->{mv_search_error}) {
return $s;
}


# clear errors for non-eval code paths below
undef $@;
if ($s->{mv_coordinate}) {
undef $f;
}
Expand All @@ -219,7 +221,6 @@ sub search {
),
@pats )};
}

$@ and return $s->search_error("Function creation: $@");

my $qual;
Expand Down
8 changes: 5 additions & 3 deletions lib/Vend/Glimpse.pm
Expand Up @@ -2,7 +2,7 @@
#
# Adapted for use with Interchange from Search::Glimpse
#
# Copyright (C) 2002-2007 Interchange Development Group
# Copyright (C) 2002-2017 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
Expand All @@ -24,7 +24,7 @@ package Vend::Glimpse;
require Vend::Search;
@ISA = qw(Vend::Search);

$VERSION = substr(q$Revision: 2.16 $, 10);
$VERSION = '2.17';
use strict;
use Vend::File;
use Vend::Util;
Expand Down Expand Up @@ -189,6 +189,8 @@ sub search {

my $joiner = $s->{mv_orsearch}[0] ? ',' : ';';

# clear errors for non-eval code paths below
undef $@;
if ($s->{mv_coordinate}) {
undef $f;
}
Expand All @@ -213,8 +215,8 @@ sub search {
),
@pats )};
}

$@ and return $s->search_error("Function creation: $@");

local($/) = $s->{mv_record_delim} || "\n";

$s->save_specs();
Expand Down
6 changes: 4 additions & 2 deletions lib/Vend/RefSearch.pm
Expand Up @@ -2,7 +2,7 @@
#
# Adapted for use with Interchange from Search::TextSearch
#
# Copyright (C) 2002-2007 Interchange Development Group
# Copyright (C) 2002-2017 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
Expand All @@ -25,7 +25,7 @@ require Vend::Search;

@ISA = qw(Vend::Search);

$VERSION = substr(q$Revision: 2.11 $, 10);
$VERSION = '2.12';

use strict;
no warnings qw(uninitialized numeric);
Expand Down Expand Up @@ -129,6 +129,8 @@ sub search {

@pats = $s->spec_check(@specs);

# clear errors for non-eval code path
undef $@;
if ($s->{mv_coordinate}) {
undef $f;
}
Expand Down
6 changes: 4 additions & 2 deletions lib/Vend/Search.pm
Expand Up @@ -964,8 +964,10 @@ EOF
::logDebug("filter function code is: $f")
if $Global::DebugFile and $CGI::values{debug};
use locale;
$f = eval $f if $f and ! ref $f;
die($@) if $@;
if ($f and ! ref $f) {
$f = eval $f;
die($@) if $@;
}
my $relate;
if(scalar @code > 1) {
$relate = 'return ( ';
Expand Down
4 changes: 3 additions & 1 deletion lib/Vend/Session.pm
@@ -1,6 +1,6 @@
# Vend::Session - Interchange session routines
#
# Copyright (C) 2002-2013 Interchange Development Group
# Copyright (C) 2002-2017 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
#
# This program was originally based on Vend 0.2 and 0.3
Expand Down Expand Up @@ -466,6 +466,8 @@ sub read_session {

#::logDebug ("Session:\n$s\n");
return new_session($seed) unless $s;

undef $@;
$Vend::Session = ref $s ? $s : evalr($s);
die "Could not eval '$s' from session dbm: $@\n" if $@;

Expand Down
4 changes: 3 additions & 1 deletion lib/Vend/Ship.pm
@@ -1,6 +1,6 @@
# Vend::Ship - Interchange shipping code
#
# Copyright (C) 2002-2015 Interchange Development Group
# Copyright (C) 2002-2017 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
#
# This program was originally based on Vend 0.2 and 0.3
Expand Down Expand Up @@ -329,6 +329,8 @@ sub read_shipping {
$zone = $1 if ! $zone;
next if defined $zones{$zone};
my $ref;
# clear errors for non-eval code paths below
undef $@;
if ($o->{zone}) {
$ref = {};
my @common = qw/
Expand Down
7 changes: 4 additions & 3 deletions lib/Vend/TextSearch.pm
Expand Up @@ -2,7 +2,7 @@
#
# Adapted for use with Interchange from Search::TextSearch
#
# Copyright (C) 2002-2008 Interchange Development Group
# Copyright (C) 2002-2017 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
Expand All @@ -27,7 +27,7 @@ require Exporter;
use vars qw(@ISA);
@ISA = qw(Vend::Search);

$VERSION = substr(q$Revision: 2.18 $, 10);
$VERSION = '2.19';

use Search::Dict;
use strict;
Expand Down Expand Up @@ -144,6 +144,8 @@ sub search {

@pats = $s->spec_check(@specs);

# clear errors for non-eval code paths
undef $@;
if ($s->{mv_coordinate}) {
undef $f;
}
Expand All @@ -164,7 +166,6 @@ sub search {
),
@pats )};
}

$@ and return $s->search_error("Function creation: $@");

local($/) = $s->{mv_record_delim} || "\n";
Expand Down

0 comments on commit 9bba0b5

Please sign in to comment.