From: Alex Riesen <raa.lkml@gmail.com>
To: Martin Waitz <tali@admingilde.org>
Cc: git@vger.kernel.org, Junio C Hamano <junkio@cox.net>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] Simplify calling of CR/LF conversion routines
Date: Sun, 22 Apr 2007 18:16:02 +0200 [thread overview]
Message-ID: <20070422161602.GD2431@steel.home> (raw)
In-Reply-To: <20070422134505.GF27208@admingilde.org>
[-- Attachment #1: Type: text/plain, Size: 318 bytes --]
Martin Waitz, Sun, Apr 22, 2007 15:45:06 +0200:
> hoi :)
>
> For me (on glibc-2.5) the testsuite fails in t0020-crlf.sh, test 14:
>
> *** glibc detected *** git: free(): invalid next size (fast): 0x081097b8 ***
Yep, already fixed. The patches attached (I forgot which one was the
fix for this particular problem).
[-- Attachment #2: 0001-Fix-crash-in-t0020-crlf-conversion.patch --]
[-- Type: text/x-diff, Size: 1427 bytes --]
>From 001f0b86bc4142743eea242649fb188807e03c16 Mon Sep 17 00:00:00 2001
From: Alex Riesen <raa.lkml@gmail.com>
Date: Sun, 22 Apr 2007 16:03:49 +0200
Subject: [PATCH] Fix crash in t0020 (crlf conversion)
Reallocated wrong size.
Noticed on Ubuntu 7.04 probably because it has some malloc diagnostics in libc:
"git-read-tree --reset -u HEAD" aborted in the test. Valgrind sped up the
debugging greatly: took me 10 minutes.
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
attr.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/attr.c b/attr.c
index 285e689..a071254 100644
--- a/attr.c
+++ b/attr.c
@@ -300,7 +300,8 @@ static struct attr_stack *read_attr_from_array(const char **list)
a = parse_attr_line(line, "[builtin]", ++lineno, 1);
if (!a)
continue;
- res->attrs = xrealloc(res->attrs, res->num_matches + 1);
+ res->attrs = xrealloc(res->attrs,
+ sizeof(struct match_attr *) * (res->num_matches + 1));
res->attrs[res->num_matches++] = a;
}
return res;
@@ -324,7 +325,8 @@ static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
a = parse_attr_line(buf, path, ++lineno, macro_ok);
if (!a)
continue;
- res->attrs = xrealloc(res->attrs, res->num_matches + 1);
+ res->attrs = xrealloc(res->attrs,
+ sizeof(struct match_attr *) * (res->num_matches + 1));
res->attrs[res->num_matches++] = a;
}
fclose(fp);
--
1.5.1.1.946.gdb75a
[-- Attachment #3: 0002-Fix-a-typo-in-crlf-conversion-code.patch --]
[-- Type: text/x-diff, Size: 1723 bytes --]
>From e306988bdabf5dec30c945167bfaa5f5f2c16835 Mon Sep 17 00:00:00 2001
From: Alex Riesen <raa.lkml@gmail.com>
Date: Sun, 22 Apr 2007 16:07:19 +0200
Subject: [PATCH] Fix a typo in crlf conversion code
Also, noticed by valgrind: the code caused a read out-of-bounds.
Some comments updated as well (they still reflected old calling
conventions).
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
convert.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/convert.c b/convert.c
index 37239ac..ad106ef 100644
--- a/convert.c
+++ b/convert.c
@@ -115,8 +115,8 @@ static char *crlf_to_git(const char *path, const char *src, unsigned long *sizep
}
/*
- * Ok, allocate a new buffer, fill it in, and return true
- * to let the caller know that we switched buffers on it.
+ * Ok, allocate a new buffer, fill it in, and return it
+ * to let the caller know that we switched buffers.
*/
nsize = size - stats.crlf;
buffer = xmalloc(nsize);
@@ -137,7 +137,7 @@ static char *crlf_to_git(const char *path, const char *src, unsigned long *sizep
} else {
do {
unsigned char c = *src++;
- if (! (c == '\r' && (1 < size && *buffer == '\n')))
+ if (! (c == '\r' && (1 < size && *src == '\n')))
*dst++ = c;
} while (--size);
}
@@ -180,8 +180,8 @@ static char *crlf_to_worktree(const char *path, const char *src, unsigned long *
}
/*
- * Ok, allocate a new buffer, fill it in, and return true
- * to let the caller know that we switched buffers on it.
+ * Ok, allocate a new buffer, fill it in, and return it
+ * to let the caller know that we switched buffers.
*/
nsize = size + stats.lf - stats.crlf;
buffer = xmalloc(nsize);
--
1.5.1.1.946.gdb75a
next prev parent reply other threads:[~2007-04-22 16:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-18 22:28 [PATCH] Simplify calling of CR/LF conversion routines Alex Riesen
2007-04-18 23:03 ` Alex Riesen
2007-04-22 13:45 ` Martin Waitz
2007-04-22 16:16 ` Alex Riesen [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-04-19 0:05 Alex Riesen
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=20070422161602.GD2431@steel.home \
--to=raa.lkml@gmail.com \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=tali@admingilde.org \
--cc=torvalds@linux-foundation.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).