threads / patch / 17626

patchfix uninitialized variable in string_expand_length

Subject: [PATCH] fix uninitialized variable in string_expand_length

## tl;dr

2 messages between Feb 7, 2009 and Feb 8, 2009. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Jeff King· Feb 7, 2009, 10:37 UTC · lore

This led to totally unpredictable results from the function. The style matches the loop in string_expand.

Signed-off-by: Jeff King <peff@peff.net>
---
 tig.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to tig.c +1 −1
diff --git a/tig.c b/tig.c
index 79afdb1..97794b0 100644
--- a/tig.c
+++ b/tig.c
@@ -193,7 +193,7 @@ string_expand_length(const char *line, int tabsize)
 {
 	size_t size, pos;
 
-	for (pos = 0; line[pos]; pos++) {
+	for (size = pos = 0; line[pos]; pos++) {
 		if (line[pos] == '\t' && tabsize > 0)
 			size += tabsize - (size % tabsize);
 		else
-- 
1.6.1.2.552.g1682c.dirty
Jonas Fonseca· Feb 8, 2009, 09:58 UTC · re: Jeff King · lore

Re: [PATCH] fix uninitialized variable in string_expand_length

On Sat, Feb 7, 2009 at 11:37, Jeff King <peff@peff.net> wrote:
> This led to totally unpredictable results from the function. The style
> matches the loop in string_expand.
Oops, thanks.
-- 
Jonas Fonseca

← back to recent threads