From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH] list-objects: perform NULL check before the variable is dereferenced
Date: Mon, 9 Apr 2012 17:45:11 +0700 [thread overview]
Message-ID: <1333968311-29889-1-git-send-email-pclouds@gmail.com> (raw)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
list-objects.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/list-objects.c b/list-objects.c
index 3dd4a96..34044d9 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -15,12 +15,13 @@ static void process_blob(struct rev_info *revs,
const char *name,
void *cb_data)
{
- struct object *obj = &blob->object;
+ struct object *obj;
if (!revs->blob_objects)
return;
- if (!obj)
+ if (!blob)
die("bad blob object");
+ obj = &blob->object;
if (obj->flags & (UNINTERESTING | SEEN))
return;
obj->flags |= SEEN;
@@ -67,7 +68,7 @@ static void process_tree(struct rev_info *revs,
const char *name,
void *cb_data)
{
- struct object *obj = &tree->object;
+ struct object *obj;
struct tree_desc desc;
struct name_entry entry;
struct name_path me;
@@ -77,8 +78,9 @@ static void process_tree(struct rev_info *revs,
if (!revs->tree_objects)
return;
- if (!obj)
+ if (!tree)
die("bad tree object");
+ obj = &tree->object;
if (obj->flags & (UNINTERESTING | SEEN))
return;
if (parse_tree(tree) < 0)
--
1.7.3.1.256.g2539c.dirty
next reply other threads:[~2012-04-09 10:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-09 10:45 Nguyễn Thái Ngọc Duy [this message]
2012-04-09 18:51 ` [PATCH] list-objects: perform NULL check before the variable is dereferenced Junio C Hamano
2012-04-09 23:47 ` Nguyen Thai Ngoc Duy
2012-04-10 0:09 ` Junio C Hamano
2012-04-10 0:09 ` 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=1333968311-29889-1-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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;
as well as URLs for NNTP newsgroup(s).