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

[PATCH] use xstrdup, not strdup in ll-merge.c

From
Jim Meyering <jim@meyering.net>
Date
Jun 14, 2009, 19:47 UTC
Message-ID
<87bpoqoavp.fsf@meyering.net>

Otherwise, a fluky allocation failure would cause merge configuration settings to be silently ignored.

Signed-off-by: Jim Meyering <meyering@redhat.com>
---
 ll-merge.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/ll-merge.c b/ll-merge.c
index 31d6f0a..9168958 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -231,7 +231,7 @@ static int read_merge_config(const char *var, const char *value, void *cb)

 	if (!strcmp(var, "merge.default")) {
 		if (value)
-			default_ll_merge = strdup(value);
+			default_ll_merge = xstrdup(value);
 		return 0;
 	}

@@ -265,7 +265,7 @@ static int read_merge_config(const char *var, const char *value, void *cb)
 	if (!strcmp("name", ep)) {
 		if (!value)
 			return error("%s: lacks value", var);
-		fn->description = strdup(value);
+		fn->description = xstrdup(value);
 		return 0;
 	}

@@ -288,14 +288,14 @@ static int read_merge_config(const char *var, const char *value, void *cb)
 		 * file named by %A, and signal that it has done with zero exit
 		 * status.
 		 */
-		fn->cmdline = strdup(value);
+		fn->cmdline = xstrdup(value);
 		return 0;
 	}

 	if (!strcmp("recursive", ep)) {
 		if (!value)
 			return error("%s: lacks value", var);
-		fn->recursive = strdup(value);
+		fn->recursive = xstrdup(value);
 		return 0;
 	}

--
1.6.3.2.406.gd6a466
Next: Alex Riesen
Message 1 of 10 in “use xstrdup, not strdup in ll-merge.c”
  1. use xstrdup, not strdup in ll-merge.cJim Meyering, Jun 14, 2009
  2. Alex RiesenJun 14, 2009
  3. Jim MeyeringJun 15, 2009
  4. Alex RiesenJun 15, 2009
  5. Jim MeyeringJun 15, 2009
  6. Alex RiesenJun 15, 2009
  7. Jim MeyeringJun 15, 2009
  8. Alex RiesenJun 15, 2009
  9. Shawn O. PearceJun 15, 2009
  10. Alex RiesenJun 15, 2009

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.