summaryrefslogtreecommitdiff
path: root/ext/SDBM_File/SDBM_File.xs
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-05-24 13:34:45 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-05-24 13:34:45 +0000
commit8a0b16eb60065835f8d356f329e2b8cbfe8c9d62 (patch)
treedcbb04310fa7707abc7d7b725ba54661ea966a5f /ext/SDBM_File/SDBM_File.xs
parentcdfe229e642682dd52e04cdd1232a90648b35fe3 (diff)
downloadperl-8a0b16eb60065835f8d356f329e2b8cbfe8c9d62.tar.gz
Fix segfault in SDBM_File when the destructor is called multiple times
p4raw-id: //depot/perl@28298
Diffstat (limited to 'ext/SDBM_File/SDBM_File.xs')
-rw-r--r--ext/SDBM_File/SDBM_File.xs22
1 files changed, 12 insertions, 10 deletions
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)