AmendHub

Download:

jcs

/

subtext

/

amendments

/

592

board: free post_ids in board_index_sorted_post_ids


jcs made amendment 592 8 months ago
--- board.c Thu Feb 15 16:43:16 2024 +++ board.c Fri Feb 16 08:42:43 2024 @@ -1543,9 +1543,9 @@ board_index_sorted_post_ids(struct board *board, struct board_post post; struct board_thread thread; size_t ret, size, i, j, n, npost_ids, nthread_ids; - unsigned long *post_ids, *thread_ids; + unsigned long *post_ids = NULL, *thread_ids = NULL; struct board_id_time_map *id_map, tmp_id_map; - struct thread_time_map *thread_map, tmp_thread_map; + struct thread_time_map *thread_map = NULL, tmp_thread_map; char *data; if (board->ftn_area[0]) { @@ -1571,6 +1571,8 @@ board_index_sorted_post_ids(struct board *board, id_map[n].time = fpost.time; } + xfree(&post_ids); + /* sort by date descending */ for (i = 1; i < npost_ids; i++) { for (j = i; j > 0; j--) { @@ -1668,7 +1670,14 @@ board_index_sorted_post_ids(struct board *board, xfree(&thread_map); } -write_out: +write_out: + if (thread_map) + xfree(&thread_map); + if (thread_ids) + xfree(&thread_ids); + if (post_ids) + xfree(&post_ids); + if (npost_ids == 0 || id_map == NULL) { board_delete_cached_index(board); if (sorted_id_map != NULL)