about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--ext/sleepy_penguin/init.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/ext/sleepy_penguin/init.c b/ext/sleepy_penguin/init.c
index 27aada4..76fa77a 100644
--- a/ext/sleepy_penguin/init.c
+++ b/ext/sleepy_penguin/init.c
@@ -101,15 +101,13 @@ static struct rb_sp_tlsbuf *alloc_tlsbuf(size_t size)
         size_t bytes = size + sizeof(struct rb_sp_tlsbuf);
         struct rb_sp_tlsbuf *buf;
         void *ptr;
-        int err = posix_memalign(&ptr, rb_sp_l1_cache_line_size, bytes);
 
-        if (err) {
-                errno = err;
+        if (size >= UINT32_MAX ||
+            posix_memalign(&ptr, rb_sp_l1_cache_line_size, bytes))
                 rb_memerror(); /* fatal */
-        }
 
         buf = ptr;
-        buf->capa = size;
+        buf->capa = (uint32_t)size;
 
         return buf;
 }