Subject: Re: [PATCH] compat/mingw: brown paper bag fix for 50a6c8e

From: Junio C Hamano <[email-masked]>
Date: Mon, 29 Feb 2016 11:10:09 -0800

Jeff King <[email-masked]> writes:

> On Mon, Feb 29, 2016 at 10:56:22AM +0100, Torsten Bögershausen wrote:
>
>> Thanks for the fast-patch.
>> 
>> I manually copied the patch, But there are more probles, it seems.
>> 
>> $ git diff
>> diff --git a/compat/mingw.c b/compat/mingw.c
>> index cfedcf9..b1163f2 100644
>> --- a/compat/mingw.c
>> +++ b/compat/mingw.c
>> @@ -1069,7 +1069,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const
>> char **argv, char **deltaen
>>                         free(quoted);
>>         }
>> 
>> -       wargs = xmalloc_array(st_add(st_mult(2, args.len), 1), sizeof(wchar_t));
>> +       wargs = ALLOC_ARRAY(st_add(st_mult(2, args.len), 1), sizeof(wchar_t));
>>         xutftowcs(wargs, args.buf, 2 * args.len + 1);
>>         strbuf_release(&args);
>
> Argh. Let me write "git commit -a" on the inside of my brown paper bag,
> so that I actually send out the fix sitting in my working tree, not the
> half-finished thing I ran "git add" on.

Just to make sure that I am not confused, what you wrote below
matches what I received from you two message upthread.

I am assuming that it is intended that the two messages from you
have the same patch, and the assignment of ALLOC_ARRAY to wargs was
a bug Torsten introduced only to his tree when cutting and pasting.

With that assumption, will queue this one (or the original one,
which to me is the same thing).

Thanks.

> -- >8 --
> Subject: [PATCH] compat/mingw: brown paper bag fix for 50a6c8e
>
> Commit 50a6c8e (use st_add and st_mult for allocation size
> computation, 2016-02-22) fixed up many xmalloc call-sites
> including ones in compat/mingw.c.
>
> But I screwed up one of them, which was half-converted to
> ALLOC_ARRAY, using a very early prototype of the function.
> And I never caught it because I don't build on Windows.
>
> Signed-off-by: Jeff King <[email-masked]>
> ---
>  compat/mingw.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/compat/mingw.c b/compat/mingw.c
> index cfedcf9..54c82ec 100644
> --- a/compat/mingw.c
> +++ b/compat/mingw.c
> @@ -1069,7 +1069,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
>  			free(quoted);
>  	}
>  
> -	wargs = xmalloc_array(st_add(st_mult(2, args.len), 1), sizeof(wchar_t));
> +	ALLOC_ARRAY(wargs, st_add(st_mult(2, args.len), 1));
>  	xutftowcs(wargs, args.buf, 2 * args.len + 1);
>  	strbuf_release(&args);