mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Do a memberwise comparison of threading function tables
Doing a memcmp risks comparing uninitialized padding bytes at the end of the structure.
This commit is contained in:
parent
438d4ff2bd
commit
c94a5f2a2c
13
evthread.c
13
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user