Code

Make <identifier> lowercase as per CodingGuidelines
[git.git] / wrapper.c
index 4c1639f1536d259a2b64d574005ac973d042b273..79635f2e1628a1ac25d62ca502c9ee4d0a2b61d6 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -12,6 +12,8 @@ static void (*try_to_free_routine)(size_t size) = do_nothing;
 try_to_free_t set_try_to_free_routine(try_to_free_t routine)
 {
        try_to_free_t old = try_to_free_routine;
+       if (!routine)
+               routine = do_nothing;
        try_to_free_routine = routine;
        return old;
 }
@@ -51,7 +53,7 @@ void *xmalloc(size_t size)
 void *xmallocz(size_t size)
 {
        void *ret;
-       if (size + 1 < size)
+       if (unsigned_add_overflows(size, 1))
                die("Data too large to fit into virtual memory space.");
        ret = xmalloc(size + 1);
        ((char*)ret)[size] = 0;