Re: [PATCH 01/15] string_list: add string_list_duplicate
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 27, 2016, 21:11 UTC
- Message-ID
- <xmqqzise7o4l.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <CAGZ79kbWMN3YG5Jtz8i8Y9A3id8bX-YxSWp19+yGAdzMX_wKKA@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
Show 8 quoted lines
> When not duplicating git_config_get_value_multi("submodule.defaultGroup");
> I run into
>
> Program received signal SIGSEGV, Segmentation fault.
> ...
> So the string list seems to be corrupted here.
> Someone stomping over our memory? How long is the result
> of git_config_get_value_multi deemed to be stable and usable?That call goes to
git_config_get_value_multi()
-> git_configset_get_value_multi()
-> configset_find_element()the returned value from there would be either NULL or the list of values that belong to the config cache layer, i.e. a caller of the API can peek but is not allowed to modify it.
So if you are modifying the value you obtain from the API, you must make a copy; otherwise you will "stomp over" memory that belongs to the config cache layer, not to you.