[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/3] grep: reset state after truncated or invalid multibyte s

From: Paolo Bonzini
Subject: Re: [PATCH 2/3] grep: reset state after truncated or invalid multibyte sequences
Date: Wed, 24 Mar 2010 17:19:25 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20100301 Fedora/3.0.3-1.fc12 Lightning/1.0b2pre Thunderbird/3.0.3

On 03/24/2010 05:17 PM, Jim Meyering wrote:
Paolo Bonzini wrote:
From: Norihirio Tanaka<address@hidden>

* src/searchutils.c (is_mb_middle): When treating an invalid sequence
or a truncated multibyte character as a single byte character, reset
  src/searchutils.c |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/searchutils.c b/src/searchutils.c
index ef4fef3..960e3ba 100644
--- a/src/searchutils.c
+++ b/src/searchutils.c
@@ -131,6 +131,7 @@ is_mb_middle(const char **good, const char *buf, const char 
          /* An invalid sequence, or a truncated multibyte character.
             We treat it as a single byte character.  */
          mbclen = 1;
+         memset(mbstate, 0, sizeof(mbstate_t));
        p += mbclen;

Thank you for the patch.
Do either of you have a test case?

No, or I would have included it. But it matches what grep does in general to handle this case.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]