git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "mark via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: mark <870355373@qq.com>, wangsirun <wangsirun@zhidaoauto.com>
Subject: [PATCH] fix: check parameters in json-write.c
Date: Tue, 19 Sep 2023 11:54:58 +0000	[thread overview]
Message-ID: <pull.1576.git.git.1695124498925.gitgitgadget@gmail.com> (raw)

From: wangsirun <wangsirun@zhidaoauto.com>

When I used the json-writer.c file as a lib, I found that
it often caused coredump errors, so I submitted this patch

Signed-off-by: sirun Wang <870355373@qq.com>
---
    fix: check parameters in json-write.c
    
    When I used the json-writer.c file as a lib, I found that it often
    caused coredump errors, so I submitted this patch

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1576%2Fwangsirun%2Fjson-write-fix-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1576/wangsirun/json-write-fix-v1
Pull-Request: https://github.com/git/git/pull/1576

 json-writer.c | 5 +++++
 1 file changed, 5 insertions(+)

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;
+	}
+
 	strbuf_addch(out, '"');
 	while ((c = *in++) != '\0') {
 		if (c == '"')

base-commit: d4a83d07b8cc66d4afac2f33a8af729f2ba93bba
-- 
gitgitgadget

             reply	other threads:[~2023-09-19 11:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-19 11:54 mark via GitGitGadget [this message]
2023-09-19 17:48 ` [PATCH] fix: check parameters in json-write.c Taylor Blau
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=pull.1576.git.git.1695124498925.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=870355373@qq.com \
    --cc=git@vger.kernel.org \
    --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).