From 95a7b9f48afa4586df9482c3ca4b55e268e45429 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Mon, 17 Sep 2012 20:38:59 +0000 Subject: [PATCH] More consistent return errors... git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1386822 13f79535-47bb-0310-9956-ffa450edef68 --- modules/slotmem/mod_slotmem_shm.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/slotmem/mod_slotmem_shm.c b/modules/slotmem/mod_slotmem_shm.c index 780bdaed06..bdc46ad80e 100644 --- a/modules/slotmem/mod_slotmem_shm.c +++ b/modules/slotmem/mod_slotmem_shm.c @@ -489,7 +489,7 @@ static apr_status_t slotmem_dptr(ap_slotmem_instance_t *slot, return APR_ENOSHMAVAIL; } if (id >= slot->desc.num) { - return APR_ENOSHMAVAIL; + return APR_EINVAL; } ptr = (char *)slot->base + slot->desc.size * id; @@ -512,7 +512,10 @@ static apr_status_t slotmem_get(ap_slotmem_instance_t *slot, unsigned int id, } inuse = slot->inuse + id; - if (id >= slot->desc.num || (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse)) { + if (id >= slot->desc.num) { + return APR_EINVAL; + } + if (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse) { return APR_NOTFOUND; } ret = slotmem_dptr(slot, id, &ptr); @@ -536,7 +539,10 @@ static apr_status_t slotmem_put(ap_slotmem_instance_t *slot, unsigned int id, } inuse = slot->inuse + id; - if (id >= slot->desc.num || (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse)) { + if (id >= slot->desc.num) { + return APR_EINVAL; + } + if (AP_SLOTMEM_IS_PREGRAB(slot) && !*inuse) { return APR_NOTFOUND; } ret = slotmem_dptr(slot, id, &ptr); @@ -618,7 +624,11 @@ static apr_status_t slotmem_release(ap_slotmem_instance_t *slot, "slotmem(%s) release failed. Num %u/inuse[%u] %d", slot->name, slotmem_num_slots(slot), id, (int)inuse[id]); - return APR_NOTFOUND; + if (id >= slot->desc.num) { + return APR_EINVAL; + } else { + return APR_NOTFOUND; + } } inuse[id] = 0; (*slot->num_free)++; -- 2.40.0