diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bf731991..7c49dd24c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -345,6 +345,12 @@ if(NOT WIN32) list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) endif() +if(WITH_VALGRIND_MEMCHECK) + check_include_files(valgrind/memcheck.h HAVE_VALGRIND_MEMCHECK_H) +else() + unset(HAVE_VALGRIND_MEMCHECK_H CACHE) +endif() + if(UNIX OR CYGWIN) check_include_files(sys/eventfd.h HAVE_AIO_H) check_include_files(sys/eventfd.h HAVE_EVENTFD_H) diff --git a/cmake/ConfigOptions.cmake b/cmake/ConfigOptions.cmake index 915d114d4..00ce2edb1 100644 --- a/cmake/ConfigOptions.cmake +++ b/cmake/ConfigOptions.cmake @@ -44,6 +44,10 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_COMPILER_IS_CLANG 1) endif() +if(NOT WIN32) + option(WITH_VALGRIND_MEMCHECK "Compile with valgrind helpers." OFF) +endif() + if(MSVC) option(WITH_NATIVE_SSPI "Use native SSPI modules" ON) option(WITH_WINMM "Use Windows Multimedia" ON) diff --git a/config.h.in b/config.h.in index aed1f6f09..043dae23d 100755 --- a/config.h.in +++ b/config.h.in @@ -25,6 +25,7 @@ #cmakedefine HAVE_TM_GMTOFF #cmakedefine HAVE_AIO_H #cmakedefine HAVE_PTHREAD_GNU_EXT +#cmakedefine HAVE_VALGRIND_MEMCHECK_H /* Options */ diff --git a/libfreerdp/crypto/tls.c b/libfreerdp/crypto/tls.c index 1c12a9459..52c217782 100644 --- a/libfreerdp/crypto/tls.c +++ b/libfreerdp/crypto/tls.c @@ -31,6 +31,10 @@ #include +#ifdef HAVE_VALGRIND_MEMCHECK_H +#include +#endif + static CryptoCert tls_get_certificate(rdpTls* tls, BOOL peer) { CryptoCert cert; @@ -465,6 +469,10 @@ int tls_read(rdpTls* tls, BYTE* data, int length) } } +#ifdef HAVE_VALGRIND_MEMCHECK_H + VALGRIND_MAKE_MEM_DEFINED(data, status); +#endif + return status; }