summaryrefslogtreecommitdiff
path: root/stagit.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2017-04-16 20:59:23 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2017-04-16 20:59:23 +0200
commitf9e7dc80702317cf5b9c764eeec89e2cbde8c982 (patch)
tree68bb7f7f9ff33c236282b36a891d072abb62c2c2 /stagit.c
parent44b20f341443cf3daffbe2b092df28df522cad86 (diff)
writeblobhtml: fix possible uninitialized variable n when len == 0
... whoops
Diffstat (limited to 'stagit.c')
-rw-r--r--stagit.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/stagit.c b/stagit.c
index 09f3df7..f438a02 100644
--- a/stagit.c
+++ b/stagit.c
@@ -378,7 +378,7 @@ writefooter(FILE *fp)
int
writeblobhtml(FILE *fp, const git_blob *blob)
{
- size_t n, i, prev;
+ size_t n = 0, i, prev;
const char *nfmt = "<a href=\"#l%d\" class=\"line\" id=\"l%d\">%6d</a> ";
const char *s = git_blob_rawcontent(blob);
git_off_t len = git_blob_rawsize(blob);
@@ -386,7 +386,7 @@ writeblobhtml(FILE *fp, const git_blob *blob)
fputs("<pre id=\"blob\">\n", fp);
if (len > 0) {
- for (i = 0, prev = 0, n = 0; i < (size_t)len; i++) {
+ for (i = 0, prev = 0; i < (size_t)len; i++) {
if (s[i] != '\n')
continue;
n++;