From ffb414b233f695a35ee2c7666ce9579aeed7f369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Mon, 7 Apr 2008 18:49:24 +0000 Subject: [PATCH] make refcount slightly more sane. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22855 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/hx509/crypto.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/hx509/crypto.c b/lib/hx509/crypto.c index 7876a9b93..e16977c6b 100644 --- a/lib/hx509/crypto.c +++ b/lib/hx509/crypto.c @@ -1592,11 +1592,11 @@ _hx509_private_key_init(hx509_private_key *key, hx509_private_key _hx509_private_key_ref(hx509_private_key key) { - if (key->ref <= 0) - _hx509_abort("refcount <= 0"); - key->ref++; if (key->ref == 0) - _hx509_abort("refcount == 0"); + _hx509_abort("key refcount <= 0 on ref"); + key->ref++; + if (key->ref == UINT_MAX) + _hx509_abort("key refcount == UINT_MAX on ref"); return key; } @@ -1612,8 +1612,8 @@ _hx509_private_key_free(hx509_private_key *key) if (key == NULL || *key == NULL) return 0; - if ((*key)->ref <= 0) - _hx509_abort("refcount <= 0"); + if ((*key)->ref == 0) + _hx509_abort("key refcount == 0 on free"); if (--(*key)->ref > 0) return 0;