fix segfault bug that could happen in rare fail code path of test5

Thread 1 "xperable" received signal SIGSEGV, Segmentation fault.
0x0814d191 in memcpy ()
This commit is contained in:
j4nn 2026-01-17 22:29:02 +01:00
commit 0bf7060a96

View file

@ -531,9 +531,11 @@ static int test5(struct fbusb *dev, int size, int offset, const char *fname)
if (res != FASTBOOT_DATA) {
if (*(uint32_t *)rxbuff != 0)
return -1;
i -= 4;
memmove(rxbuff, rxbuff + 4, i);
memset(rxbuff + i, 0, 4);
if (i > 4) {
i -= 4;
memmove(rxbuff, rxbuff + 4, i);
memset(rxbuff + i, 0, 4);
}
}
size = 0;
addr = 0;