summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsinisterchipmunk <sinisterchipmunk@gmail.com>2020-01-22 02:30:22 -0500
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-05-23 14:29:16 +0900
commitaa1d3c7d2c020ec927acaa487e8593172fb64bb0 (patch)
treed78113cbad13af8f098f32d9e7601d58d039f1ee
parentad729a1d11c6c57efd2e92803b4e937db0f75252 (diff)
[ruby/fiddle] Initialize memory to 0 when calling Fiddle.malloc(). (#24)
https://github.com/ruby/fiddle/commit/8414239ca3
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3068
-rw-r--r--ext/fiddle/fiddle.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/fiddle/fiddle.c b/ext/fiddle/fiddle.c
index 9f3d1537d6..bb6b1070d3 100644
--- a/ext/fiddle/fiddle.c
+++ b/ext/fiddle/fiddle.c
@@ -47,8 +47,9 @@ static VALUE
rb_fiddle_malloc(VALUE self, VALUE size)
{
void *ptr;
-
- ptr = (void*)ruby_xmalloc(NUM2SIZET(size));
+ size_t sizet = NUM2SIZET(size);
+ ptr = (void*)ruby_xmalloc(sizet);
+ memset(ptr, 0, sizet);
return PTR2NUM(ptr);
}