Skip to content

Commit

Permalink
fy-diag: Guard against bad input when outputting diags
Browse files Browse the repository at this point in the history
Guard against something being off when calculating error message
output.

Signed-off-by: Pantelis Antoniou <[email protected]>
  • Loading branch information
pantoniou committed Apr 22, 2024
1 parent 1f520e6 commit b9178e7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/fy-diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,11 @@ void fy_diag_error_atom_display(struct fy_diag *diag, enum fy_error_type type, s
/* optimize by using the content end as a starting point */
s = l->content_start + l->content_len;
e = l->line_start + l->line_count;

/* guard against something stupid */
if (s > e)
s = e;

col8 = l->content_end_col8;
while ((c = fy_utf8_get(s, (e - s), &w)) >= 0) {
s += w;
Expand Down

0 comments on commit b9178e7

Please sign in to comment.