From c94a5f2a2cce7b6751a95343e0d80b7d150add31 Mon Sep 17 00:00:00 2001 From: Nate R Date: Tue, 24 Jan 2012 17:15:50 -0500 Subject: [PATCH] Do a memberwise comparison of threading function tables Doing a memcmp risks comparing uninitialized padding bytes at the end of the structure. --- evthread.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/evthread.c b/evthread.c index 734b77c5..765d7346 100644 --- a/evthread.c +++ b/evthread.c @@ -84,7 +84,12 @@ evthread_set_lock_callbacks(const struct evthread_lock_callbacks *cbs) } if (target->alloc) { /* Uh oh; we already had locking callbacks set up.*/ - if (!memcmp(target, cbs, sizeof(_evthread_lock_fns))) { + if (target->lock_api_version == cbs->lock_api_version && + target->supported_locktypes == cbs->supported_locktypes && + target->alloc == cbs->alloc && + target->free == cbs->free && + target->lock == cbs->lock && + target->unlock == cbs->unlock) { /* no change -- allow this. */ return 0; } @@ -117,7 +122,11 @@ evthread_set_condition_callbacks(const struct evthread_condition_callbacks *cbs) } if (target->alloc_condition) { /* Uh oh; we already had condition callbacks set up.*/ - if (!memcmp(target, cbs, sizeof(_evthread_cond_fns))) { + if (target->condition_api_version == cbs->condition_api_version && + target->alloc_condition == cbs->alloc_condition && + target->free_condition == cbs->free_condition && + target->signal_condition == cbs->signal_condition && + target->wait_condition == cbs->wait_condition) { /* no change -- allow this. */ return 0; }