From 126e76dc035bd1320cb103c39ad52849844e7448 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Tue, 4 Jul 2017 08:40:29 +0200 Subject: [PATCH] core: mem/qm - fixed pointer expressions in qm_check() debug function --- src/core/mem/q_malloc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/mem/q_malloc.c b/src/core/mem/q_malloc.c index 0c24ef24098..3c34c2c09fd 100644 --- a/src/core/mem/q_malloc.c +++ b/src/core/mem/q_malloc.c @@ -728,18 +728,22 @@ void qm_check(struct qm_block* qm) abort(); }; #endif - if (f + sizeof(struct qm_frag) + f->size + sizeof(struct qm_frag_end) > qm->first_frag + qm->size) { + if ((char*)f + sizeof(struct qm_frag) + f->size + + sizeof(struct qm_frag_end) > (char*)qm->first_frag + qm->size) { LOG(L_CRIT, "BUG: qm_*: fragm. %p (address %p) " "bad size: %lu (frag end: %p > end of block: %p)\n", - f, (char*)f + sizeof(struct qm_frag) + sizeof(struct qm_frag_end), f->size, - f + sizeof(struct qm_frag) + f->size, qm->first_frag + qm->size); + f, (char*)f + sizeof(struct qm_frag), f->size, + (char*)f + sizeof(struct qm_frag) + f->size + + sizeof(struct qm_frag_end), + (char*)qm->first_frag + qm->size); qm_status(qm); abort(); } /* check struct qm_frag_end */ if (FRAG_END(f)->size != f->size) { LOG(L_CRIT, "BUG: qm_*: fragm. %p (address %p) " - "size in qm_frag and qm_frag_end does not match: frag->size=%lu, frag_end->size=%lu)\n", + "size in qm_frag and qm_frag_end does not match:" + " frag->size=%lu, frag_end->size=%lu)\n", f, (char*)f + sizeof(struct qm_frag), f->size, FRAG_END(f)->size); qm_status(qm);