diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-06-20 14:27:59 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-08-31 19:06:56 +0200 |
commit | 5f1011ac0ad676d1e7eaba14d1384180e98fb93e (patch) | |
tree | 4c4b37623d138c593d4d9220e4444d39fde2abd9 /libtrivfs | |
parent | 334801c52c9844c06eacbe2e3af65852f7412e3c (diff) |
include: detect use-after-free errors using the reference counts
* include/refcount.h (refcount_init): There must be at least one
reference at initialization time.
(refcounts_init): Likewise.
(refcount_unsafe_ref): New function retaining the previous
functionality of refcount_ref. It is occasionally useful to raise the
reference count again after it dropped to zero.
(refcounts_unsafe_ref): Likewise.
(refcounts_unsafe_weak_ref): Likewise.
(refcount_ref): Detect use-after-free errors.
(refcounts_ref): Likewise.
(refcounts_ref_weak): Likewise.
* libtrivfs/protid-clean.c (trivfs_clean_protid): Use refcount_unsafe_ref.
Diffstat (limited to 'libtrivfs')
-rw-r--r-- | libtrivfs/protid-clean.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libtrivfs/protid-clean.c b/libtrivfs/protid-clean.c index adc5e981..ff6cc167 100644 --- a/libtrivfs/protid-clean.c +++ b/libtrivfs/protid-clean.c @@ -36,7 +36,7 @@ trivfs_clean_protid (void *arg) if (refcount_deref (&cred->po->refcnt) == 0) { /* Reacquire a reference while we call the hook. */ - refcount_ref (&cred->po->refcnt); + refcount_unsafe_ref (&cred->po->refcnt); (*trivfs_peropen_destroy_hook) (cred->po); if (refcount_deref (&cred->po->refcnt) == 0) { |