diff --git a/lib/xy.h b/lib/xy.h index 2faff3a9..37c17713 100644 --- a/lib/xy.h +++ b/lib/xy.h @@ -473,6 +473,8 @@ static char * _xy_str_to_terminal_style (int style, const char *str) { char *color_fmt_str = NULL; + size_t len; + char *buf; if (!xy.enable_color) { @@ -511,8 +513,8 @@ _xy_str_to_terminal_style (int style, const char *str) new_str: // -2 把中间%s减掉 - size_t len = strlen (color_fmt_str) - 2; - char *buf = malloc (strlen (str) + len + 1); + len = strlen (color_fmt_str) - 2; + buf = malloc (strlen (str) + len + 1); sprintf (buf, color_fmt_str, str); return buf; }