[PATCH] list-objects: perform NULL check before the variable is dereferenced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]