diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-05-24 13:34:45 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-05-24 13:34:45 +0000 |
commit | 8a0b16eb60065835f8d356f329e2b8cbfe8c9d62 (patch) | |
tree | dcbb04310fa7707abc7d7b725ba54661ea966a5f /ext | |
parent | cdfe229e642682dd52e04cdd1232a90648b35fe3 (diff) | |
download | perl-8a0b16eb60065835f8d356f329e2b8cbfe8c9d62.tar.gz |
Fix segfault in SDBM_File when the destructor is called multiple times
p4raw-id: //depot/perl@28298
Diffstat (limited to 'ext')
-rw-r--r-- | ext/SDBM_File/SDBM_File.pm | 2 | ||||
-rw-r--r-- | ext/SDBM_File/SDBM_File.xs | 22 |
2 files changed, 13 insertions, 11 deletions
diff --git a/ext/SDBM_File/SDBM_File.pm b/ext/SDBM_File/SDBM_File.pm index 07a05e1d49..d1209e0158 100644 --- a/ext/SDBM_File/SDBM_File.pm +++ b/ext/SDBM_File/SDBM_File.pm @@ -7,7 +7,7 @@ require Tie::Hash; use XSLoader (); our @ISA = qw(Tie::Hash); -our $VERSION = "1.05"; +our $VERSION = "1.06"; XSLoader::load 'SDBM_File', $VERSION; diff --git a/ext/SDBM_File/SDBM_File.xs b/ext/SDBM_File/SDBM_File.xs index 24b2b833e5..6aafb6b99f 100644 --- a/ext/SDBM_File/SDBM_File.xs +++ b/ext/SDBM_File/SDBM_File.xs @@ -53,16 +53,18 @@ void sdbm_DESTROY(db) SDBM_File db CODE: - sdbm_close(db->dbp); - if (db->filter_fetch_key) - SvREFCNT_dec(db->filter_fetch_key) ; - if (db->filter_store_key) - SvREFCNT_dec(db->filter_store_key) ; - if (db->filter_fetch_value) - SvREFCNT_dec(db->filter_fetch_value) ; - if (db->filter_store_value) - SvREFCNT_dec(db->filter_store_value) ; - safefree(db) ; + if (db) { + sdbm_close(db->dbp); + if (db->filter_fetch_key) + SvREFCNT_dec(db->filter_fetch_key) ; + if (db->filter_store_key) + SvREFCNT_dec(db->filter_store_key) ; + if (db->filter_fetch_value) + SvREFCNT_dec(db->filter_fetch_value) ; + if (db->filter_store_value) + SvREFCNT_dec(db->filter_store_value) ; + safefree(db) ; + } datum_value sdbm_FETCH(db, key) |