AmendHub

Download:

jcs

/

subtext

/

amendments

/

395

board: Fix writing new sorted id after creating a post


jcs made amendment 395 about 1 year ago
--- board.c Fri Mar 10 14:03:28 2023 +++ board.c Fri Mar 10 22:05:01 2023 @@ -1092,14 +1092,18 @@ board_post_create(struct board *board, struct board_th size = (o ? o->size : 0) + sizeof(unsigned long); npost_ids = (o ? (o->size / sizeof(unsigned long)) : 0) + 1; post_ids = xmalloc(size); - if (post_ids == NULL) + if (post_ids == NULL) { + if (o) + xfree(&o); goto done; - if (o) - bile_read(board->bile, BOARD_SORTED_IDS_RTYPE, 1, - post_ids + sizeof(unsigned long), o->size); + } post_ids[0] = post->id; - bile_write(board->bile, BOARD_SORTED_IDS_RTYPE, 1, post_ids, - size); + if (o) { + bile_read(board->bile, BOARD_SORTED_IDS_RTYPE, 1, + post_ids + 1, o->size); + xfree(&o); + } + bile_write(board->bile, BOARD_SORTED_IDS_RTYPE, 1, post_ids, size); } else { if (!post->time) post->time = Time;