about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2018-07-14 05:34:32 +0000
committerEric Wong <e@80x24.org>2018-07-16 19:34:32 +0000
commitd95aeb450fec9c4e4836179f7cdf6fcafba3e119 (patch)
tree4ffcb67390532b147e046d53c4e739fb1773df32
parent383c26ea407cf130ad63edfca5bee44e6b282252 (diff)
downloadmwrap-d95aeb450fec9c4e4836179f7cdf6fcafba3e119.tar.gz
Oops :x
-rw-r--r--ext/mwrap/mwrap.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/ext/mwrap/mwrap.c b/ext/mwrap/mwrap.c
index c0cf8ff..fa52631 100644
--- a/ext/mwrap/mwrap.c
+++ b/ext/mwrap/mwrap.c
@@ -408,12 +408,14 @@ static void *internal_memalign(size_t alignment, size_t size, uintptr_t caller)
         /* assert(asize == (alignment + size + sizeof(struct alloc_hdr))); */
         rcu_read_lock();
         l = update_stats_rcu(size, caller);
-        real = real_malloc(asize);
-        p = hdr2ptr(real);
-        if (!ptr_is_aligned(p, alignment))
-                p = ptr_align(p, alignment);
-        h = ptr2hdr(p);
-        alloc_insert_rcu(l, h, size, real);
+        p = real = real_malloc(asize);
+        if (real) {
+                p = hdr2ptr(real);
+                if (!ptr_is_aligned(p, alignment))
+                        p = ptr_align(p, alignment);
+                h = ptr2hdr(p);
+                alloc_insert_rcu(l, h, size, real);
+        }
         rcu_read_unlock();
 
         return p;