Attention is currently required from: Felix Singer, Edward O'Callaghan, Angel Pons.
Anastasia Klimchuk has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/70006 )
Change subject: layout: Check return values for strdup in register_include_arg ......................................................................
Patch Set 4:
(4 comments)
File layout.c:
https://review.coreboot.org/c/flashrom/+/70006/comment/f07643a8_a4ca4b9a PS2, Line 139: || file == NULL
Line 144 causes a memory leak now. […]
Oh yes, thanks for spotting memory leak! I missed that, fixed by `goto error`.
The option you said prefer (moving the code) does not compile, I tried that at some point earlier locally (between patchset 2 and 3), the reason is: ``` ../layout.c: In function ‘register_include_arg’: ../layout.c:170:9: error: ‘name’ may be used uninitialized [-Werror=maybe-uninitialized] 170 | free(name); | ^~~~~~~~~~ ``` (line number might be out of date).
Handling the `name` first, `file` second solves the issue. This also means all error paths (for name, file and below) are treated by `goto error`, looks nice and consistent.
File layout.c:
https://review.coreboot.org/c/flashrom/+/70006/comment/b2316f42_28504fd3 PS3, Line 135: if (name == NULL) {
nit: `!name`
Done
https://review.coreboot.org/c/flashrom/+/70006/comment/cee1d3e0_a50fe7c7 PS3, Line 142: if(!colon[1]) {
mising space `if (`
Done
https://review.coreboot.org/c/flashrom/+/70006/comment/a4347779_12ec7822 PS3, Line 148: if (file == NULL) {
nit: `!file`
Done