]> git.vpit.fr Git - perl/scripts/xchat.git/blobdiff - Xchat/XPI/Utils.pm
Make sure local_context() runs the code only when the context was found
[perl/scripts/xchat.git] / Xchat / XPI / Utils.pm
index 0b4bff91b7266fa72e4ff65c617e81e9d310efcb..c8994abd6b5e7ed616be2247390560e9c074a31f 100644 (file)
@@ -51,9 +51,10 @@ sub local_context {
  return unless @_ >= 2;
  my $code    = pop;
  my $new_cxt = (@_ == 1) ? $_[0] : find_context(@_);
+ return undef unless defined $new_cxt;
  my $cur_cxt = get_context;
+ my $guard   = bless \$cur_cxt, 'Xchat::XPI::Utils::ContextGuard';
  if (set_context $new_cxt) {
-  my $guard = bless \$cur_cxt, 'Xchat::XPI::Utils::ContextGuard';
   return $code->();
  } else {
   return undef;