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

duplicate memory allocation in buildin-add.c

From
LYLiu Yubao <yubao.liu@gmail.com>
Date
Sep 15, 2006, 11:26 UTC
Message-ID
<450A8DFF.9040605@gmail.com>
http://www.kernel.org/git/?p=git/git.git;a=commitdiff;h=0d78153952e70c21e94dc6b7eefcb2ac5337a902
buildin-add.c:
+static void fill_directory(struct dir_struct *dir, const char **pathspec)
+{
+ 	const char *path, *base;
+ 	int baselen;
...
+ 	if (baselen) {
+ 		char *common = xmalloc(baselen + 1);
+ 		common = xmalloc(baselen + 1);
+ 		memcpy(common, *pathspec, baselen);
+ 		common[baselen] = 0;
+ 		path = base = common;
+ 	}
...
Allocate memory twice for "common" variable, is it indended? I'm very confused @_@
Message 1 of 1 in “duplicate memory allocation in buildin-add.c”
  1. Liu YubaoSep 15, 2006

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.