Thread (16 messages) 16 messages, 5 authors, 7d ago

Re: [PATCH 3/6] wrapper: create safe_memory_limit_check()

From: Junio C Hamano <hidden>
Date: 2026-09-21 21:24:30

"Derrick Stolee via GitGitGadget" [off-list ref] writes:
+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?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help