Skip to content

Commit 6561310

Browse files
Minor OOM check in PIO support routines
1 parent bac6dae commit 6561310

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

cores/rp2040/SerialPIO.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ static pio_program_t *pio_make_uart_prog(int repl, const pio_program_t *pg) {
3636
p->length = pg->length;
3737
p->origin = pg->origin;
3838
uint16_t *insn = (uint16_t *)malloc(p->length * 2);
39+
if (!insn) {
40+
delete p;
41+
return nullptr;
42+
}
3943
memcpy(insn, pg->instructions, p->length * 2);
4044
insn[0] = pio_encode_set(pio_x, repl);
4145
p->instructions = insn;

0 commit comments

Comments
 (0)