# [PATCH] fix uninitialized variable in string_expand_length

2 messages from 2009-02-07 to 2009-02-08. Participants: Jeff King, Jonas Fonseca.
Thread: https://gitlist.dev/t/17626

## Jeff King, 2009-02-07 10:37

Subject: [PATCH] fix uninitialized variable in string_expand_length
Message-ID: <20090207103723.GA18823@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20090207103723.GA18823%40coredump.intra.peff.net

```
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(-)

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, 2009-02-08 09:58

Subject: Re: [PATCH] fix uninitialized variable in string_expand_length
Message-ID: <2c6b72b30902080158t569ac25er3eb725035d4550d2@mail.gmail.com>
URL: https://gitlist.dev/e/2c6b72b30902080158t569ac25er3eb725035d4550d2%40mail.gmail.com
In-Reply-To: <20090207103723.GA18823@coredump.intra.peff.net>

```
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

```
