[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 2/4] grep: reset state after truncated or invalid multibyt
From: |
Jim Meyering |
Subject: |
Re: [PATCH v2 2/4] grep: reset state after truncated or invalid multibyte sequences |
Date: |
Thu, 25 Mar 2010 11:10:37 +0100 |
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
> mbstate
> ---
> src/searchutils.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/src/searchutils.c b/src/searchutils.c
> index ef4fef3..20c2d0c 100644
> --- a/src/searchutils.c
> +++ b/src/searchutils.c
> @@ -131,6 +131,7 @@ is_mb_middle(const char **good, const char *buf, const
> char *end)
> /* An invalid sequence, or a truncated multibyte character.
> We treat it as a single byte character. */
> mbclen = 1;
> + memset(&cur_state, 0, sizeof(mbstate_t));
Please change that line to this:
memset(&cur_state, 0, sizeof cur_state);
I have a strong preference for that style
(using "sizeof VARIABLE" rather than "sizeof TYPE"),
since it is more maintainable and more readable.
I would prefer to have a test case that fails without this change,
but if it's not forthcoming right away, I won't insist.