git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] fix: check parameters in json-write.c

From
MGmark via GitGitGadget <gitgitgadget@gmail.com>
Date
Sep 19, 2023, 11:54 UTC
Message-ID
<pull.1576.git.git.1695124498925.gitgitgadget@gmail.com>
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
Next: Taylor Blau
Message 1 of 4 in “fix: check parameters in json-write.c”
  1. fix: check parameters in json-write.cmark via GitGitGadget, Sep 19, 2023
  2. Taylor BlauSep 19, 2023
  3. Jeff HostetlerSep 20, 2023
  4. Junio C HamanoSep 20, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.