-
Problem report
-
Resolution: Fixed
-
Trivial
-
2.2.21
-
Sprint 28, Sprint 29
-
0.5
The following code uses chunk's first_value and last_value properties after the chunk is freed. In current memory allocator implementation it works normally, as the freed memory block is not changed by current process and valuecache shared memory is locked during this operation and cannot be changed by other processes.
However the approach is obviously wrong and there might be problems if the memory allocator is changed in future, so it's better to fix it.
static size_t vch_item_free_chunk(zbx_vc_item_t *item, zbx_vc_chunk_t *chunk) { size_t freed; freed = vc_item_free_values(item, chunk->slots, chunk->first_value, chunk->last_value); __vc_mem_free_func(chunk); return freed + sizeof(zbx_vc_chunk_t) + (chunk->last_value - chunk->first_value) * sizeof(zbx_history_record_t); }