Re: [PATCH 2/3] remote.c: don't dereference NULL in freeing loop
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 7, 2022, 17:23 UTC
- Message-ID
- <xmqqpmjkxu9s.fsf@gitster.g>
- In-Reply-To
- <patch-2.3-0e258c230f6-20220607T154520Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> Fix a bug in fd3cb0501e1 (remote: move static variables into > per-repository struct, 2021-11-17) where we'd free(remote->pushurl[i]) > after having NULL'd out remote->pushurl. itself. We free
Wow, that's a bad one. Why didn't anybody notice this at runtime, I have to wonder.
Show 8 quoted lines
> for (i = 0; i < remote->url_nr; i++) > free((char *)remote->url[i]); > - FREE_AND_NULL(remote->pushurl); > + FREE_AND_NULL(remote->url); > > for (i = 0; i < remote->pushurl_nr; i++) > free((char *)remote->pushurl[i]); > FREE_AND_NULL(remote->pushurl);
Thanks.