From 503badb5d14cc7d7b1d0fcd6d148d441d923f83e Mon Sep 17 00:00:00 2001 From: usa Date: Fri, 14 Feb 2014 06:19:25 +0000 Subject: merge revision(s) 44731,44751: [Backport #8978] * ext/fiddle/closure.c: use sizeof(*pcl) for correct sizeof value. [ruby-core:57599] [Bug #8978]. Thanks mame! * ext/fiddle/closure.c: use sizeof(*pcl) for correct sizeof value. [ruby-core:57599] [Bug #8978]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@44941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/fiddle/closure.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c index 21796660c4..a1413206fd 100644 --- a/ext/fiddle/closure.c +++ b/ext/fiddle/closure.c @@ -21,7 +21,7 @@ dealloc(void * ptr) #ifndef DONT_USE_FFI_CLOSURE_ALLOC ffi_closure_free(cls->pcl); #else - munmap(cls->pcl, sizeof(cls->pcl)); + munmap(cls->pcl, sizeof(*cls->pcl)); #endif if (cls->argv) xfree(cls->argv); xfree(cls); @@ -228,7 +228,10 @@ initialize(int rbargc, VALUE argv[], VALUE self) #else result = ffi_prep_closure(pcl, cif, callback, (void *)self); cl->code = (void *)pcl; - mprotect(pcl, sizeof(pcl), PROT_READ | PROT_EXEC); + i = mprotect(pcl, sizeof(*pcl), PROT_READ | PROT_EXEC); + if (i) { + rb_sys_fail("mprotect"); + } #endif if (FFI_OK != result) -- cgit v1.2.3