diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-08-05 15:04:50 +0200 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-08-05 15:04:50 +0200 |
commit | 55356470f9fe0b60bd9e0db1e90dbca6b4e7db63 (patch) | |
tree | 0020b6e8207f8a65bbb044cf82d218b9c3a9f301 /src/lib/shm_du_map.c | |
parent | 93e3e8f3864436d67bba617df5565680c3997542 (diff) | |
download | ouroboros-55356470f9fe0b60bd9e0db1e90dbca6b4e7db63.tar.gz ouroboros-55356470f9fe0b60bd9e0db1e90dbca6b4e7db63.zip |
lib:shm_du_map: Fix wrong element access
The check whether the du map is empty should be first.
Diffstat (limited to 'src/lib/shm_du_map.c')
-rw-r--r-- | src/lib/shm_du_map.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lib/shm_du_map.c b/src/lib/shm_du_map.c index 6527e035..8d197232 100644 --- a/src/lib/shm_du_map.c +++ b/src/lib/shm_du_map.c @@ -91,13 +91,14 @@ static void garbage_collect(struct shm_du_map * dum) { #ifdef SHM_DU_MAP_MULTI_BLOCK struct shm_du_buff * sdb; - while ((sdb = get_tail_ptr(dum))->dst_api == -1 && - !shm_map_empty(dum)) + while (!shm_map_empty(dum) && + (sdb = get_tail_ptr(dum))->dst_api == -1) + *dum->ptr_tail = (*dum->ptr_tail + sdb->blocks) & (SHM_BUFFER_SIZE - 1); #else - while (get_tail_ptr(dum)->dst_api == -1 && - !shm_map_empty(dum)) + while (!shm_map_empty(dum) && + get_tail_ptr(dum)->dst_api == -1) *dum->ptr_tail = (*dum->ptr_tail + 1) & (SHM_BUFFER_SIZE - 1); |