Re: [PATCH 3/6] wrapper: create safe_memory_limit_check()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 21, 2026, 21:24 UTC
- Message-ID
- <xmqqzexal2lv.fsf@gitster.g>
- In-Reply-To
- <3b3c67243d200a42aa105981b64228e2cbb35a6c.1789736540.git.gitgitgadget@gmail.com>
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 11 quoted lines
> +static int safe_memory_limit_check(size_t size, int verbose)
> {
> + size_t limit = git_alloc_limit ? git_alloc_limit : SIZE_MAX;
> + if (size > limit) {
> + if (verbose)
> error("attempting to allocate %"PRIuMAX" over limit %"PRIuMAX,
> (uintmax_t)size, (uintmax_t)git_alloc_limit);
> + return -1;
> }
> return 0;
> }The code is prepared for a case where git_alloc_limit is set to 0, in which case SIZE_MAX is used as a stand-in value. When the check detects a request with overly large 'size', the error message tells us that 'size' is over 'git_alloc_limit', the latter is zero and any concrete value of 'size' certainly would be over that. Which may be a bit confusing.
Shouldn't we be giving the local "limit" instead in the message?