X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/cc8bc92ae4a8e9f1a1ab61bf83d34ad8150b3405..5c9f46613a83ebfc29a5b1f099448259e96a98f0:/bsd/kern/sys_reason.c diff --git a/bsd/kern/sys_reason.c b/bsd/kern/sys_reason.c index 16ea4cfe4..ea260cdc3 100644 --- a/bsd/kern/sys_reason.c +++ b/bsd/kern/sys_reason.c @@ -278,7 +278,9 @@ os_reason_ref(os_reason_t cur_reason) lck_mtx_lock(&cur_reason->osr_lock); assert(cur_reason->osr_refcount > 0); - cur_reason->osr_refcount++; + if (os_add_overflow(cur_reason->osr_refcount, 1, &cur_reason->osr_refcount)) { + panic("os reason refcount overflow"); + } lck_mtx_unlock(&cur_reason->osr_lock); @@ -298,7 +300,9 @@ os_reason_free(os_reason_t cur_reason) lck_mtx_lock(&cur_reason->osr_lock); - assert(cur_reason->osr_refcount > 0); + if (cur_reason->osr_refcount == 0) { + panic("os_reason_free called on reason with zero refcount"); + } cur_reason->osr_refcount--; if (cur_reason->osr_refcount != 0) {