Skip to content

Commit

Permalink
CLEANUP: avoid UBSAN error in mkvmi.c
Browse files Browse the repository at this point in the history
The error is raised because we have e5 -= 0 for e5 == NULL

else-branch of if ( !e4 || (is_vmh && !e5) )
<=> e4 && !(is_vmh && !e5)
<=> e4 && (!is_vmh || e5)

Consequence is e4-- (which is fine) and e5 -= is_vmh which is either a noop* for is_vmh == 0 or fine for is_vmh != 0 && e5 != NULL.

The noop case raises the error if e5 == NULL.
  • Loading branch information
mgondan authored and JanWielemaker committed May 3, 2024
1 parent 1a795a4 commit 321ea1c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/mkvmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ load_vmis(const char *file)
exit(1);
} else
{ e4--; /* backspace over ) */
e5 -= is_vmh;
if ( e5 )
e5 -= is_vmh;
}

vmi_list[vmi_count].name = my_strndup(s1, e1-s1);
Expand Down

0 comments on commit 321ea1c

Please sign in to comment.