From 275baa51c93a43138867c5f27155324cf8b1b3af Mon Sep 17 00:00:00 2001 From: Slaven Rezic Date: Tue, 9 Dec 2008 18:39:31 +0100 Subject: [PATCH] * no more segfault if CheckSV is called before NoteSV --- Leak.xs | 4 ++++ t/basic.t | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) mode change 100644 => 100755 t/basic.t diff --git a/Leak.xs b/Leak.xs index 59b2390..19ff42c 100644 --- a/Leak.xs +++ b/Leak.xs @@ -157,6 +157,10 @@ find_object(void *p, SV *sv, long count) long check_used(hash_ptr **x) {hash_ptr *ht = *x; + if (ht == 0) + { + croak("Please call Devel::Check::NoteSV() before calling Devel::Check::CheckSV()"); + } long count = sv_apply_to_used(ht, check_sv, 0); long i; for (i = 0; i < MAX_HASH; i++) diff --git a/t/basic.t b/t/basic.t old mode 100644 new mode 100755 index d84eb49..926675f --- a/t/basic.t +++ b/t/basic.t @@ -1,9 +1,13 @@ use Test; -plan test => 3; +plan test => 4; eval { require Devel::Leak }; ok($@, "", "loading module"); eval { import Devel::Leak }; ok($@, "", "running import"); + +eval { Devel::Leak::CheckSV($handle) }; +ok($@ =~ /\QPlease call Devel::Check::NoteSV() before calling Devel::Check::CheckSV()/, 1, "no segfault"); + @somewhere = (); my $count = Devel::Leak::NoteSV($handle); print "$count SVs so far\n"; -- 2.11.4.GIT