From: Junio C Hamano <gitster@pobox•com>
To: Karthik Nayak <karthik.188@gmail•com>
Cc: git@vger•kernel.org, sunshine@sunshineco•com
Subject: Re: [PATCH v7 1/4] sha1_file.c: support reading from a loose object of unknown type
Date: Sat, 04 Apr 2015 12:34:04 -0700 [thread overview]
Message-ID: <xmqq7ftrg02b.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1428126162-18987-1-git-send-email-karthik.188@gmail.com> (Karthik Nayak's message of "Sat, 4 Apr 2015 11:12:42 +0530")
Karthik Nayak <karthik.188@gmail•com> writes:
> @@ -2586,13 +2649,15 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
> *(oi->disk_sizep) = 0;
> if (oi->delta_base_sha1)
> hashclr(oi->delta_base_sha1);
> + if (oi->typename)
> + strbuf_addstr(oi->typename, typename(co->type));
> oi->whence = OI_CACHED;
> return 0;
> }
Just before the pre-context of this hunk, there is this bit:
if (oi->typep)
*(oi->typep) = co->type;
which tells me that the callers of this function is allowed to pass
a NULL in oi->typep when they are not interested in the type of the
object.
> if (!find_pack_entry(real, &e)) {
> /* Most likely it's a loose object. */
> - if (!sha1_loose_object_info(real, oi)) {
> + if (!sha1_loose_object_info(real, oi, flags)) {
> oi->whence = OI_LOOSE;
> return 0;
> }
> @@ -2616,6 +2681,8 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
> oi->u.packed.is_delta = (rtype == OBJ_REF_DELTA ||
> rtype == OBJ_OFS_DELTA);
> }
> + if (oi->typename)
> + strbuf_addstr(oi->typename, typename(*oi->typep));
So, it makes me wonder what guarantee we have that this does not
dereference a NULL here.
next prev parent reply other threads:[~2015-04-04 19:34 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-04 5:41 [PATCH v7 0/4] cat-file: teach cat-file a '--literally' option karthik nayak
2015-04-04 5:42 ` [PATCH v7 1/4] sha1_file.c: support reading from a loose object of unknown type Karthik Nayak
2015-04-04 19:34 ` Junio C Hamano [this message]
2015-04-04 19:53 ` karthik nayak
2015-04-05 7:46 ` Junio C Hamano
2015-04-05 7:52 ` karthik nayak
2015-04-05 19:57 ` Junio C Hamano
2015-04-07 10:34 ` karthik nayak
2015-04-05 18:28 ` Karthik Nayak
2015-04-07 20:46 ` Eric Sunshine
2015-04-04 5:44 ` [PATCH v7 2/4] cat-file: teach cat-file a '--literally' option Karthik Nayak
2015-04-07 20:49 ` Eric Sunshine
2015-04-04 5:44 ` [PATCH v7 3/4] cat-file: add documentation for " Karthik Nayak
2015-04-07 20:49 ` Eric Sunshine
2015-04-04 5:44 ` [PATCH v7 4/4] t1006: add tests for git cat-file --literally Karthik Nayak
2015-04-07 20:49 ` Eric Sunshine
2015-04-08 17:42 ` karthik nayak
2015-04-08 20:34 ` Eric Sunshine
2015-04-09 3:24 ` Karthik Nayak
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=xmqq7ftrg02b.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=karthik.188@gmail$(echo .)com \
--cc=sunshine@sunshineco$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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