From: Kevin Day Date: Sat, 22 Jul 2023 15:33:12 +0000 (-0500) Subject: Security: The f_iki allocation functions are calling f_memory_destroy() and f_memory_... X-Git-Tag: 0.6.7~18 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=909f2cb4f4ea3355354b88657438cc64623b5c09;p=fll Security: The f_iki allocation functions are calling f_memory_destroy() and f_memory_delete() when they should not, causing memory leak. The private_f_iki_datas_adjust() should be called instead of f_memory_destroy(). The private_f_iki_datas_resize() should be called instead of f_memory_delete(). This is because the iki_datass needs the individual sets within to be deallocated. De-allocating at the top level via the f_memory_destroy() and f_memory_delete() is very probably a memory leak. --- diff --git a/level_0/f_iki/c/iki/private-data.c b/level_0/f_iki/c/iki/private-data.c index 9be4bc3..0a16fc6 100644 --- a/level_0/f_iki/c/iki/private-data.c +++ b/level_0/f_iki/c/iki/private-data.c @@ -169,11 +169,8 @@ extern "C" { for (f_array_length_t i = length; i < datass->size; ++i) { - status = f_memory_destroy(datass->array[i].size, sizeof(f_iki_datas_t), (void **) & datass->array[i].array); + status = private_f_iki_datas_adjust(0, &datass->array[i]); if (F_status_is_error(status)) return status; - - datass->array[i].size = 0; - datass->array[i].used = 0; } // for status = f_memory_adjust(datass->size, length, sizeof(f_iki_datas_t), (void **) & datass->array); @@ -196,11 +193,8 @@ extern "C" { for (f_array_length_t i = length; i < datass->size; ++i) { - status = f_memory_delete(datass->array[i].size, sizeof(f_iki_datas_t), (void **) & datass->array[i].array); + status = private_f_iki_datas_resize(0, &datass->array[i]); if (F_status_is_error(status)) return status; - - datass->array[i].size = 0; - datass->array[i].used = 0; } // for status = f_memory_resize(datass->size, length, sizeof(f_iki_datas_t), (void **) & datass->array);