[PATCH] reftable: use xmalloc() and xrealloc()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



malloc(3) and realloc(3) can fail and return NULL.  None of the reftable
code checks for that possibility and would happily dereference NULL
pointers.  Use xmalloc() and xrealloc() instead like in the rest of Git
to report allocation errors and exit cleanly, and to also honor the
environment variable GIT_ALLOC_LIMIT.

Signed-off-by: René Scharfe <l.s.r@xxxxxx>
---
 reftable/publicbasics.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/reftable/publicbasics.c b/reftable/publicbasics.c
index 44b84a125e..f33a65df34 100644
--- a/reftable/publicbasics.c
+++ b/reftable/publicbasics.c
@@ -19,14 +19,14 @@ void *reftable_malloc(size_t sz)
 {
 	if (reftable_malloc_ptr)
 		return (*reftable_malloc_ptr)(sz);
-	return malloc(sz);
+	return xmalloc(sz);
 }

 void *reftable_realloc(void *p, size_t sz)
 {
 	if (reftable_realloc_ptr)
 		return (*reftable_realloc_ptr)(p, sz);
-	return realloc(p, sz);
+	return xrealloc(p, sz);
 }

 void reftable_free(void *p)
--
2.44.0





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux