stagit

writeblobhtml: fix possible uninitialized variable n when len == 0

... whoops

Hiltjo Posthuma contact@arjunchoudhary.com

commit: 9328d86 parent: f082d2b
1 files changed, 2 insertions(+), 2 deletions(-)
Mstagit.c+2-2
M · stagit.c +2, -2
 1@@ -378,7 +378,7 @@ writefooter(FILE *fp)
 2 int
 3 writeblobhtml(FILE *fp, const git_blob *blob)
 4 {
 5-	size_t n, i, prev;
 6+	size_t n = 0, i, prev;
 7 	const char *nfmt = "<a href=\"#l%d\" class=\"line\" id=\"l%d\">%6d</a> ";
 8 	const char *s = git_blob_rawcontent(blob);
 9 	git_off_t len = git_blob_rawsize(blob);
10@@ -386,7 +386,7 @@ writeblobhtml(FILE *fp, const git_blob *blob)
11 	fputs("<pre id=\"blob\">\n", fp);
12 
13 	if (len > 0) {
14-		for (i = 0, prev = 0, n = 0; i < (size_t)len; i++) {
15+		for (i = 0, prev = 0; i < (size_t)len; i++) {
16 			if (s[i] != '\n')
17 				continue;
18 			n++;