git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Kastrup <dak@gnu.org>
To: git@vger.kernel.org
Cc: David Kastrup <dak@gnu.org>
Subject: [PATCH] builtin/blame.c::prepare_lines: fix allocation size of sb->lineno
Date: Sat,  8 Feb 2014 10:19:26 +0100	[thread overview]
Message-ID: <1391851166-10393-1-git-send-email-dak@gnu.org> (raw)

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

             reply	other threads:[~2014-02-08  9:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-08  9:19 David Kastrup [this message]
2014-02-08  9:49 ` [PATCH] builtin/blame.c::prepare_lines: fix allocation size of sb->lineno David Kastrup
2014-02-08 21:21   ` Jeff King
2014-02-08 21:34     ` David Kastrup

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1391851166-10393-1-git-send-email-dak@gnu.org \
    --to=dak@gnu.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).