git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] parse-options-cb.c: use string_list_append_nodup in OPT_STRING_LIST()
@ 2016-06-10 11:57 Nguyễn Thái Ngọc Duy
  2016-06-12 22:03 ` Jeff King
  0 siblings, 1 reply; 15+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2016-06-10 11:57 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

If the given string list has strdup_strings set (*), the string will be
duplicated again. Pointless and leak memory. Ignore that flag.

(*) only interpret-trailers.c does it at the moment

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 parse-options-cb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parse-options-cb.c b/parse-options-cb.c
index 239898d..8a1b6e6 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -144,7 +144,7 @@ int parse_opt_string_list(const struct option *opt, const char *arg, int unset)
 	if (!arg)
 		return -1;
 
-	string_list_append(v, xstrdup(arg));
+	string_list_append_nodup(v, xstrdup(arg));
 	return 0;
 }
 
-- 
2.8.2.524.g6ff3d78

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-08-03  7:37 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-10 11:57 [PATCH] parse-options-cb.c: use string_list_append_nodup in OPT_STRING_LIST() Nguyễn Thái Ngọc Duy
2016-06-12 22:03 ` Jeff King
2016-06-13  0:08   ` Duy Nguyen
2016-06-13  5:32     ` [PATCH 0/3] fix parse-opt string_list leaks Jeff King
2016-06-13  5:39       ` [PATCH 1/3] parse_opt_string_list: stop allocating new strings Jeff King
2016-06-13  5:39       ` [PATCH 2/3] interpret-trailers: don't duplicate option strings Jeff King
2016-06-13  5:39       ` [PATCH 3/3] blame,shortlog: don't make local option variables static Jeff King
2016-06-14  4:32         ` Eric Sunshine
2016-06-14  5:05           ` Jeff King
2016-08-02 10:52             ` [PATCH] blame: drop strdup of string literal Jeff King
2016-08-03  7:36               ` Eric Sunshine
2016-06-13  9:36       ` [PATCH 0/3] fix parse-opt string_list leaks Duy Nguyen
2016-06-13 10:04         ` [PATCH 4/3] use string_list initializer consistently Jeff King
2016-06-13 11:31           ` Duy Nguyen
2016-06-13 17:32             ` Jeff King

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).