Thread (1 message) 1 message, 1 author, 2019-08-20

Re: [PATCH 1/1] quote: handle null and empty strings in sq_quote_buf_pretty()

From: Junio C Hamano <hidden>
Date: 2019-08-20 20:32:10

"Garima Singh via GitGitGadget" [off-list ref] writes:
+	/*
+	 * In case of null or empty tokens, add a '' to ensure we 
+	 * don't inadvertently drop those tokens
+	 */
A good comment.
+	if (!src || !*src) {
I think a caller that passes src==NULL deserves a BUG, or just a
normal segfault.  The condition here should just be "if (!*src)"
instead.
+		strbuf_addstr(dst, "''");
+		return;
+	}
Otherwise, the fix itself is good.

Thanks.

 	for (p = src; *p; p++) {
 		if (!isalpha(*p) && !isdigit(*p) && !strchr(ok_punct, *p)) {
 			sq_quote_buf(dst, src);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help