diff options
author | Nate R <nate_r@example.com> | 2012-01-24 17:15:50 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-01-24 17:15:50 -0500 |
commit | c94a5f2a2cce7b6751a95343e0d80b7d150add31 (patch) | |
tree | 6ce8579cda12fb50de9e81f8130a3ed9868c66e1 /evthread.c | |
parent | 438d4ff2bd2459cbb6778750f840c3667a302bfb (diff) | |
download | libevent-c94a5f2a2cce7b6751a95343e0d80b7d150add31.tar.gz |
Do a memberwise comparison of threading function tables
Doing a memcmp risks comparing uninitialized padding bytes at the
end of the structure.
Diffstat (limited to 'evthread.c')
-rw-r--r-- | evthread.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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; } |