AmendHub

Download:

jcs

/

subtext

/

amendments

/

589

board: free id_map at the end of board_delete_ftn_post

Add a missing free on error path in board_find_post_ids

jcs made amendment 589 2 months ago
--- board.c Tue Jan 23 16:25:33 2024 +++ board.c Thu Feb 15 16:43:16 2024 @@ -1133,7 +1133,7 @@ size_t board_find_post_ids(struct session *s, struct board *board, size_t *npost_ids, unsigned long **post_ids, size_t offset, size_t limit) { - struct board_id_time_map *all_post_id_map; + struct board_id_time_map *all_post_id_map = NULL; size_t n, size, nall_post_ids; *post_ids = NULL; @@ -1155,8 +1155,11 @@ board_find_post_ids(struct session *s, struct board *b nall_post_ids = size / sizeof(struct board_id_time_map); *post_ids = xcalloc(sizeof(long), MIN(limit, nall_post_ids)); - if (*post_ids == NULL) + if (*post_ids == NULL) { + if (all_post_id_map != NULL) + xfree(&all_post_id_map); return 0; + } for (n = 0; n < nall_post_ids; n++) { if (n < offset) @@ -1523,6 +1526,8 @@ board_delete_ftn_post(struct board *board, struct boar sizeof(struct board_id_time_map) * npost_ids); /* TODO: delete from msgid cache too */ + + xfree(&id_map); } size_t