From: Taylor Blau <me@ttaylorr.com>
To: mark via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, mark <870355373@qq.com>,
wangsirun <wangsirun@zhidaoauto.com>,
Jeff Hostetler <jeffhostetler@github.com>
Subject: Re: [PATCH] fix: check parameters in json-write.c
Date: Tue, 19 Sep 2023 13:48:13 -0400 [thread overview]
Message-ID: <ZQne3ThSw6HVmNJc@nand.local> (raw)
In-Reply-To: <pull.1576.git.git.1695124498925.gitgitgadget@gmail.com>
[+cc Jeff Hostetler]
On Tue, Sep 19, 2023 at 11:54:58AM +0000, mark via GitGitGadget wrote:
> diff --git a/json-writer.c b/json-writer.c
> index 005c820aa42..23ba7046e5d 100644
> --- a/json-writer.c
> +++ b/json-writer.c
> @@ -20,6 +20,11 @@ static void append_quoted_string(struct strbuf *out, const char *in)
> {
> unsigned char c;
>
> + if (!in || !*in) {
> + strbuf_addstr(out, "\"\"");
> + return;
> + }
From reading the implementation of append_quoted_string(), I think that
the case where "in" is the empty string is already covered. IOW, doing
something like:
struct strbuf buf = STRBUF_INIT;
append_quoted_string(&out, "");
warning("'%s'", buf.buf);
would print out something like:
warning: '""'
as expected. Handling a NULL "in" argument is new behavior, but I am not
sure if it is appropriate to coerce a NULL input into the empty string.
I've CC'd the author of this code, whose opinion I trust more than my
own here.
Thanks,
Taylor
next prev parent reply other threads:[~2023-09-19 17:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-19 11:54 [PATCH] fix: check parameters in json-write.c mark via GitGitGadget
2023-09-19 17:48 ` Taylor Blau [this message]
2023-09-20 20:02 ` Jeff Hostetler
2023-09-20 20:10 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZQne3ThSw6HVmNJc@nand.local \
--to=me@ttaylorr.com \
--cc=870355373@qq.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=jeffhostetler@github.com \
--cc=wangsirun@zhidaoauto.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).