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

[PATCH] builtin/blame.c::prepare_lines: fix allocation size of sb->lineno

From
David Kastrup <dak@gnu.org>
Date
Feb 8, 2014, 09:19 UTC
Message-ID
<1391851166-10393-1-git-send-email-dak@gnu.org>

If we are calling xrealloc on every single line, the least we can do is get the right allocation size.

Signed-off-by: David Kastrup <dak@gnu.org>
---
This should be less contentious than the patch in
<URL:http://permalink.gmane.org/gmane.comp.version-control.git/241561>,
Message-ID: <1391550392-17118-1-git-send-email-dak@gnu.org> as it
makes no stylistic decisions whatsoever and only fixes a clear bug.
builtin/blame.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/blame.c b/builtin/blame.c
index e44a6bb..29eb31c 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -1779,7 +1779,7 @@ static int prepare_lines(struct scoreboard *sb)
 	while (len--) {
 		if (bol) {
 			sb->lineno = xrealloc(sb->lineno,
-					      sizeof(int *) * (num + 1));
+					      sizeof(int) * (num + 1));
 			sb->lineno[num] = buf - sb->final_buf;
 			bol = 0;
 		}
@@ -1789,7 +1789,7 @@ static int prepare_lines(struct scoreboard *sb)
 		}
 	}
 	sb->lineno = xrealloc(sb->lineno,
-			      sizeof(int *) * (num + incomplete + 1));
+			      sizeof(int) * (num + incomplete + 1));
 	sb->lineno[num + incomplete] = buf - sb->final_buf;
 	sb->num_lines = num + incomplete;
 	return sb->num_lines;
-- 
1.8.3.2
Next: David Kastrup
Message 1 of 4 in “builtin/blame.c::prepare_lines: fix allocation size of sb->lineno”
  1. builtin/blame.c::prepare_lines: fix allocation size of sb->linenoDavid Kastrup, Feb 8, 2014
  2. David KastrupFeb 8, 2014
  3. Jeff KingFeb 8, 2014
  4. David KastrupFeb 8, 2014

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.