Re: [BUG] v2.16.0-rc0 seg faults when git bisect skip
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Jan 8, 2018, 15:09 UTC
- Message-ID
- <CAP8UFD1rO1cFCfZg53gG71qfbapkn3gVvja87YFiMBZTkOqNuw@mail.gmail.com>
- In-Reply-To
- <CAELBRWLV7wQm_b9Lvj67KiAMAxq6vNOzA3z62S-f5=3A5LyjZQ@mail.gmail.com>
Hi,
On Mon, Jan 8, 2018 at 3:45 PM, Yasushi SHOJI <yasushi.shoji@gmail.com> wrote:
Show 7 quoted lines
> Hi all, > > Thank you guys for insightful help. I just read the code and now I understand > what you guys are saying. Yeah, I can say the fix is "spot on". > > But, to be honest, it's hard to see why you need "if (p)" at the first glance. > So, how about this fix, instead?
+ for (p = list, i = 0; i < cnt; i++, p = p->next) {Here "i" can reach "cnt - 1" at most, so ...
+ if (i == cnt) {
+ /* clean-up unused elements if any */
+ free_commit_list(p->next);
+ p->next = NULL;
+ }... "i == cnt" is always false above. I think it should be "i == cnt - 1".
And with your code one can wonder why the cleanup is part of the loop.
> I also found a bug in show_list(). I'm attaching a patch as well.
Could you send it inline as explained in Documentation/SubmittingPatches?
Thanks, Christian.