Skip to content

Commit c960516

Browse files
committed
MT#55283 fix buffer merge logic
Oof. Change-Id: Ibc3ca28bc6c04e63b27466e62b197f6a601051f9 (cherry picked from commit f307c32)
1 parent b51cf44 commit c960516

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lib/bencode.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,10 @@ void bencode_buffer_free(bencode_buffer_t *buf) {
147147
}
148148

149149
void bencode_buffer_merge(bencode_buffer_t *to, bencode_buffer_t *from) {
150-
from->pieces->next = to->pieces;
151-
to->pieces = from->pieces;
150+
struct __bencode_buffer_piece *last = to->pieces;
151+
while (last->next)
152+
last = last->next;
153+
last->next = from->pieces;
152154
from->pieces = NULL;
153155
}
154156

0 commit comments

Comments
 (0)