Attention is currently required from: Angel Pons, Anastasia Klimchuk.
David Hendricks 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 7: Code-Review+2
(1 comment)
File layout.c:
https://review.coreboot.org/c/flashrom/+/70006/comment/53572c7d_4cc76d63 PS7, Line 123: char *file = NULL; /* file is optional, so defaults to NULL */ (consider this comment to be a non-blocking nit since the code is fine as you've written it and Edward already suggested a better refactoring idea)
Without this initialization `file` could get free()'d with a garbage value. For extra safety on top of the initialization, you might try using different labels so the program flow will skip freeing pointers that are simply unused, initialized or not. For example: ``` if (colon) { name = strndup(...); if (!name) { ... goto error_1; }
file = strndup(...); if (!file) { ... goto error_2; } }
...
error_2: free(file); error_1: free(name); return 1; ```