From: Junio C Hamano <gitster@pobox.com>
To: Tomas Carnecky <tom@dbservice.com>
Cc: git list <git@vger.kernel.org>
Subject: Re: clang static analyzer
Date: Sun, 06 Dec 2009 16:18:00 -0800 [thread overview]
Message-ID: <7vtyw3d4cn.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <33ABC714-2BCC-4910-BCAE-D331AAF2A724@dbservice.com> (Tomas Carnecky's message of "Sun\, 6 Dec 2009 07\:11\:24 +0100")
Tomas Carnecky <tom@dbservice.com> writes:
> pretty.c:get_header() - if 'line' doesn't contain a newline character,
> line is set to NULL on first iteration and then passed to strchr() in
> the second itration.
Thanks.
In practice, we will always have a newline, as we are reading from a valid
commit object in this codepath.
pretty.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/pretty.c b/pretty.c
index 8f5bd1a..7eb5384 100644
--- a/pretty.c
+++ b/pretty.c
@@ -245,11 +245,11 @@ static char *get_header(const struct commit *commit, const char *key)
int key_len = strlen(key);
const char *line = commit->buffer;
- for (;;) {
+ while (line) {
const char *eol = strchr(line, '\n'), *next;
if (line == eol)
- return NULL;
+ break;
if (!eol) {
eol = line + strlen(line);
next = NULL;
@@ -262,6 +262,7 @@ static char *get_header(const struct commit *commit, const char *key)
}
line = next;
}
+ return NULL;
}
static char *replace_encoding_header(char *buf, const char *encoding)
next prev parent reply other threads:[~2009-12-07 0:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-06 6:11 clang static analyzer Tomas Carnecky
2009-12-06 14:57 ` Jeff King
2009-12-06 15:39 ` Nicolas Pitre
2009-12-06 16:04 ` Jeff King
2009-12-06 23:49 ` Nicolas Sebrecht
2009-12-07 0:18 ` Junio C Hamano [this message]
2009-12-07 0:26 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vtyw3d4cn.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=tom@dbservice.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox