summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2010-11-13 13:16:28 -0600
committerJesse Luehrs <doy@tozt.net>2010-11-13 13:16:28 -0600
commitc86a163084d5a5fd5182c2523a07d52388a4c672 (patch)
treefbf7525d0e62a59039202c5ea7bc3fbb05839f89
parent1d6c978bb7d895ccd3ee8d9c1c2fad0d627af732 (diff)
downloadpackage-stash-xs-c86a163084d5a5fd5182c2523a07d52388a4c672.tar.gz
package-stash-xs-c86a163084d5a5fd5182c2523a07d52388a4c672.zip
also don't leak the instance on error
-rw-r--r--Stash.xs2
1 files changed, 2 insertions, 0 deletions
diff --git a/Stash.xs b/Stash.xs
index d0a9a70..12931d6 100644
--- a/Stash.xs
+++ b/Stash.xs
@@ -280,12 +280,14 @@ new(class, package_name)
if (!hv_store(instance, "name", 4, SvREFCNT_inc_simple_NN(package_name), 0)) {
SvREFCNT_dec(package_name);
+ SvREFCNT_dec(instance);
croak("Couldn't initialize the 'name' key, hv_store failed");
}
namespace = gv_stashpv(SvPV_nolen(package_name), GV_ADD);
nsref = newRV_inc((SV*)namespace);
if (!hv_store(instance, "namespace", 9, nsref, 0)) {
SvREFCNT_dec(nsref);
+ SvREFCNT_dec(instance);
croak("Couldn't initialize the 'namespace' key, hv_store failed");
}