Re: Fwd: New Defects reported by Coverity Scan for git
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 18, 2017, 17:23 UTC
- Message-ID
- <xmqqa841fylf.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <CAGZ79kaPFDMn2K0f529-Crzv+vhU3XUMsSM6w3QV4RXKBv5s_g@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
Show 11 quoted lines
> I looked at this report for a while. My current understanding: > * its detection was triggered by including rs/move-array, > f331ab9d4c (use MOVE_ARRAY, 2017-07-15) > * But it is harmless, because the scan logic does not understand > how ALLOC_GROW works. It assumes that > done_pbase_paths_alloc can be larger > than done_pbase_paths_num + 1, while done_pbase_paths > is NULL, such that the memory allocation is not triggered. > If that were the case, then we have 2 subsequent dereferences > of a NULL pointer right after that. But by inspecting the use > of _alloc and _num the initial assumption does not seem possible.
Yes, it does appear that way. ALLOC_GROW() calls REALLOC_ARRAY() which safely can realloc NULL to specified size via xrealloc().
I'd be more worried about segfault we seem to be getting only on Windows from this:
git -C parent grep -e "(1|2)d(3|4)" --recurse-submodules HEAD^ > actual
in https://travis-ci.org/git/git/jobs/254654195 by the way.