From 1ab683c478761a11c172addb6d1b4bce71c2da00 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:07 +0000 Subject: [PATCH] make refcount slightly more sane. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22851 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/hx509/keyset.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/hx509/keyset.c b/lib/hx509/keyset.c index 48574ed1b..bb36221af 100644 --- a/lib/hx509/keyset.c +++ b/lib/hx509/keyset.c @@ -59,7 +59,7 @@ RCSID("$Id$"); */ struct hx509_certs_data { - int ref; + unsigned int ref; struct hx509_keyset_ops *ops; void *ops_data; }; @@ -203,11 +203,11 @@ _hx509_certs_ref(hx509_certs certs) { if (certs == NULL) return NULL; - if (certs->ref <= 0) - _hx509_abort("certs refcount <= 0"); - certs->ref++; if (certs->ref == 0) - _hx509_abort("certs refcount == 0"); + _hx509_abort("certs refcount == 0 on ref"); + if (certs->ref == UINT_MAX) + _hx509_abort("certs refcount == UINT_MAX on ref"); + certs->ref++; return certs; } @@ -223,8 +223,8 @@ void hx509_certs_free(hx509_certs *certs) { if (*certs) { - if ((*certs)->ref <= 0) - _hx509_abort("refcount <= 0"); + if ((*certs)->ref == 0) + _hx509_abort("cert refcount == 0 on free"); if (--(*certs)->ref > 0) return;