git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix a typo in crlf conversion code
@ 2007-04-22 14:12 Alex Riesen
  2007-04-22 14:11 ` [PATCH] Fix crash in t0020 (crlf conversion) Alex Riesen
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Riesen @ 2007-04-22 14:12 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-04-22 22:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-22 14:12 [PATCH] Fix a typo in crlf conversion code Alex Riesen
2007-04-22 14:11 ` [PATCH] Fix crash in t0020 (crlf conversion) Alex Riesen
2007-04-22 22:52   ` Alex Riesen

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).