Skip to content

Commit d315cf5

Browse files
committed
patch 8.1.0021: clang warns for undefined behavior
Problem: Clang warns for undefined behavior. Solution: Move #ifdef outside of sprintf() call.(suggestion by Michael Jarvis, closes #2956)
1 parent 0b0f099 commit d315cf5

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/term.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,14 +2872,15 @@ term_color(char_u *s, int n)
28722872
#else
28732873
char *format = "%s%s%%dm";
28742874
#endif
2875-
sprintf(buf, format,
2876-
i == 2 ?
2875+
char *lead = i == 2 ? (
28772876
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
2878-
s[1] == '|' ? IF_EB("\033|", ESC_STR "|") :
2877+
s[1] == '|' ? IF_EB("\033|", ESC_STR "|") :
28792878
#endif
2880-
IF_EB("\033[", ESC_STR "[") : "\233",
2881-
s[i] == '3' ? (n >= 16 ? "38;5;" : "9")
2882-
: (n >= 16 ? "48;5;" : "10"));
2879+
IF_EB("\033[", ESC_STR "[")) : "\233";
2880+
char *tail = s[i] == '3' ? (n >= 16 ? "38;5;" : "9")
2881+
: (n >= 16 ? "48;5;" : "10");
2882+
2883+
sprintf(buf, format, lead, tail);
28832884
OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8));
28842885
}
28852886
else

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
21,
764766
/**/
765767
20,
766768
/**/

0 commit comments

Comments
 (0)