Skip to content

Commit

Permalink
Fix crash on empty newlines
Browse files Browse the repository at this point in the history
Signed-off-by: Giuliano Belinassi <[email protected]>
  • Loading branch information
giulianobelinassi committed Jul 1, 2024
1 parent 8b3abce commit 28524da
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tools/packer.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,14 @@ parse_description(const char *filename, struct ulp_metadata *ulp,
goto dsc_clean;
}

if (first[0] == '!') {
if (first[0] == '\n') {
/* Skip newline */
continue;
} else if (first[0] == '!') {
/* Lines starting with ! are comments. */
read_comment(ulp, first, n, &cur_comment_pos, &cur_comment_size);
continue;
}
else {
} else {
if (container_override) {
ulp->so_filename = strdup(container_override);
}
Expand Down Expand Up @@ -642,7 +644,10 @@ parse_description(const char *filename, struct ulp_metadata *ulp,

while (n > 0) {

if (first[0] == '!') {
if (first[0] == '\n') {
/* Skip empty lines. */
goto get_new_line;
} else if (first[0] == '!') {
/* Lines starting with ! are comments. */
read_comment(ulp, first, n, &cur_comment_pos, &cur_comment_size);
}
Expand Down Expand Up @@ -849,6 +854,7 @@ parse_description(const char *filename, struct ulp_metadata *ulp,
}

/* get new line */
get_new_line:
FREE_AND_NULLIFY(first);
second = NULL;
len = 0;
Expand Down

0 comments on commit 28524da

Please sign in to comment.