$OpenBSD: patch-subversion_bindings_swig_perl_native_Core_pm,v 1.2 2006/09/30 06:23:58 steven Exp $
--- subversion/bindings/swig/perl/native/Core.pm.orig	Thu Sep 21 16:04:11 2006
+++ subversion/bindings/swig/perl/native/Core.pm	Thu Sep 21 16:12:24 2006
@@ -50,7 +50,8 @@ BEGIN {
     SVN::_Core::apr_initialize();
 }
 
-our $gpool = SVN::Pool->new_default;
+my $gpool = SVN::Pool->new_default;
+sub gpool { $gpool } # holding the reference to gpool
 SVN::Core::utf_initialize($gpool);
 
 END {
@@ -404,9 +405,13 @@ sub _wrap {
     $npool;
 }
 
+use Scalar::Util 'reftype';
+
 sub DESTROY {
     return if $globaldestroy;
     my $self = shift;
+    # for some reason, REF becomes SCALAR in perl -c or after apr_terminate
+    return if reftype($self) eq 'SCALAR';
     if ($$self eq $SVN::_Core::current_pool) {
 	$SVN::_Core::current_pool = pop @POOLSTACK;
     }
