diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-12-23 09:32:06 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-12-23 09:32:06 -0800 |
| commit | 3151e6a1214b583552ca39c57d429a8eaa8923e8 (patch) | |
| tree | f3fee4fde1850a6d929445ab02001cc75351d50a /reftable/basics.c | |
| parent | ff795a5c5ed2e2d07c688c217a615d89e3f5733b (diff) | |
| parent | d7282891f542b58410a209230009182b9057af79 (diff) | |
| download | git-3151e6a1214b583552ca39c57d429a8eaa8923e8.tar.gz | |
Merge branch 'ps/reftable-alloc-failures-zalloc-fix'
Recent reftable updates mistook a NULL return from a request for
0-byte allocation as OOM and died unnecessarily, which has been
corrected.
* ps/reftable-alloc-failures-zalloc-fix:
reftable/basics: return NULL on zero-sized allocations
reftable/stack: fix zero-sized allocation when there are no readers
reftable/merged: fix zero-sized allocation when there are no readers
reftable/stack: don't perform auto-compaction with less than two tables
Diffstat (limited to 'reftable/basics.c')
| -rw-r--r-- | reftable/basics.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/reftable/basics.c b/reftable/basics.c index 7d84a5d62d..70b1091d14 100644 --- a/reftable/basics.c +++ b/reftable/basics.c @@ -17,6 +17,8 @@ static void (*reftable_free_ptr)(void *); void *reftable_malloc(size_t sz) { + if (!sz) + return NULL; if (reftable_malloc_ptr) return (*reftable_malloc_ptr)(sz); return malloc(sz); @@ -24,6 +26,11 @@ void *reftable_malloc(size_t sz) void *reftable_realloc(void *p, size_t sz) { + if (!sz) { + reftable_free(p); + return NULL; + } + if (reftable_realloc_ptr) return (*reftable_realloc_ptr)(p, sz); return realloc(p, sz); |
