From 1c9091ec292d0d834b920d231bb543cc34845a8f Mon Sep 17 00:00:00 2001 From: "K.Kosako" Date: Tue, 9 Jul 2019 17:32:37 +0900 Subject: [PATCH] clear buf tail after raw byte parsing --- src/regparse.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/regparse.c b/src/regparse.c index f1deea3..4ccfde5 100644 --- a/src/regparse.c +++ b/src/regparse.c @@ -6301,10 +6301,11 @@ parse_char_class(Node** np, PToken* tok, UChar** src, UChar* end, ScanEnv* env) case TK_RAW_BYTE: /* tok->base != 0 : octal or hexadec. */ if (! ONIGENC_IS_SINGLEBYTE(env->enc) && tok->base != 0) { + int i, j; UChar buf[ONIGENC_CODE_TO_MBC_MAXLEN]; UChar* bufe = buf + ONIGENC_CODE_TO_MBC_MAXLEN; UChar* psave = p; - int i, base = tok->base; + int base = tok->base; buf[0] = tok->u.c; for (i = 1; i < ONIGENC_MBC_MAXLEN(env->enc); i++) { @@ -6322,6 +6323,9 @@ parse_char_class(Node** np, PToken* tok, UChar** src, UChar* end, ScanEnv* env) goto err; } + /* clear buf tail */ + for (j = i; j < ONIGENC_CODE_TO_MBC_MAXLEN; j++) buf[j] = '\0'; + len = enclen(env->enc, buf); if (i < len) { r = ONIGERR_TOO_SHORT_MULTI_BYTE_STRING; -- 2.40.0