summaryrefslogtreecommitdiff
path: root/ext/zlib/zlib.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-15 13:26:51 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-15 13:26:51 +0000
commit8d532a868933f574ac9fe31ee11ead9a459b0914 (patch)
treee55b3f7713b197039ae95e1d24701e1f2b9fcfcd /ext/zlib/zlib.c
parent795b03c71c7949c0c260139d6f8a3e289826fdca (diff)
* 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
Diffstat (limited to 'ext/zlib/zlib.c')
-rw-r--r--ext/zlib/zlib.c21
1 files changed, 20 insertions, 1 deletions
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 <time.h>
#include <ruby/encoding.h>
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+# include <valgrind/memcheck.h>
+# 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