From d33037b5326e5f42f604fcc64d4f1d65fa5cbab8 Mon Sep 17 00:00:00 2001 From: Carlos Rueda Date: Sun, 8 Jan 2023 18:50:09 -0800 Subject: [PATCH] fix #155 - char_unescape_buffer not as shared space --- mpc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mpc.c b/mpc.c index d1ac5d2..c545557 100644 --- a/mpc.c +++ b/mpc.c @@ -601,9 +601,7 @@ static void mpc_err_string_cat(char *buffer, int *pos, int *max, char const *fmt va_end(va); } -static char char_unescape_buffer[4]; - -static const char *mpc_err_char_unescape(char c) { +static const char *mpc_err_char_unescape(char c, char char_unescape_buffer[4]) { char_unescape_buffer[0] = '\''; char_unescape_buffer[1] = ' '; @@ -633,6 +631,7 @@ char *mpc_err_string(mpc_err_t *x) { int pos = 0; int max = 1023; char *buffer = calloc(1, 1024); + char char_unescape_buffer[4]; if (x->failure) { mpc_err_string_cat(buffer, &pos, &max, @@ -657,7 +656,7 @@ char *mpc_err_string(mpc_err_t *x) { } mpc_err_string_cat(buffer, &pos, &max, " at "); - mpc_err_string_cat(buffer, &pos, &max, mpc_err_char_unescape(x->received)); + mpc_err_string_cat(buffer, &pos, &max, mpc_err_char_unescape(x->received, char_unescape_buffer)); mpc_err_string_cat(buffer, &pos, &max, "\n"); return realloc(buffer, strlen(buffer) + 1);