Skip to content

Commit c15f330

Browse files
sinisterchipmunknobu
authored andcommitted
[ruby/fiddle] Initialize memory to 0 when calling Fiddle.malloc(). (ruby#24)
ruby/fiddle@8414239ca3
1 parent 7e5253d commit c15f330

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ext/fiddle/fiddle.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ static VALUE
4747
rb_fiddle_malloc(VALUE self, VALUE size)
4848
{
4949
void *ptr;
50-
51-
ptr = (void*)ruby_xmalloc(NUM2SIZET(size));
50+
size_t sizet = NUM2SIZET(size);
51+
ptr = (void*)ruby_xmalloc(sizet);
52+
memset(ptr, 0, sizet);
5253
return PTR2NUM(ptr);
5354
}
5455

0 commit comments

Comments
 (0)