From 8d532a868933f574ac9fe31ee11ead9a459b0914 Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 15 Feb 2010 13:26:51 +0000 Subject: * ext/zlib/zlib.c (zlib_mem_alloc): suppress valgrind warnings. http://www.zlib.net/zlib_faq.html#faq36 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/zlib/zlib.c | 21 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 267c42ea9d..a464096f1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Feb 15 22:25:16 2010 Tanaka Akira + + * ext/zlib/zlib.c (zlib_mem_alloc): suppress valgrind warnings. + http://www.zlib.net/zlib_faq.html#faq36 + Mon Feb 15 22:18:49 2010 Tanaka Akira * time.c (time_add): propagate fixed time offset. diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index cfe6dd23cb..3c50b99785 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -11,6 +11,19 @@ #include #include +#ifdef HAVE_VALGRIND_MEMCHECK_H +# include +# ifndef VALGRIND_MAKE_MEM_DEFINED +# define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE(p, n) +# endif +# ifndef VALGRIND_MAKE_MEM_UNDEFINED +# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE(p, n) +# endif +#else +# define VALGRIND_MAKE_MEM_DEFINED(p, n) /* empty */ +# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) /* empty */ +#endif + #define RUBY_ZLIB_VERSION "0.6.0" @@ -436,7 +449,13 @@ static const struct zstream_funcs inflate_funcs = { static voidpf zlib_mem_alloc(voidpf opaque, uInt items, uInt size) { - return xmalloc(items * size); + voidpf p = xmalloc(items * size); + /* zlib FAQ: Valgrind (or some similar memory access checker) says that + deflate is performing a conditional jump that depends on an + uninitialized value. Isn't that a bug? + http://www.zlib.net/zlib_faq.html#faq36 */ + VALGRIND_MAKE_MEM_DEFINED(p, items * size); + return p; } static void -- cgit v1.2.3