From ad4d76422ca813a653bfcaed2d44a2e1062ce790 Mon Sep 17 00:00:00 2001 From: John Sully Date: Sun, 7 Jun 2020 23:20:10 -0400 Subject: [PATCH] Some valgrind fixes Former-commit-id: ba974c9810dc30b6b5bd21c4bcc6cc5b219f7ea4 --- src/Makefile | 2 +- src/ae.cpp | 1 + src/db.cpp | 1 + src/replication.cpp | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 8a385013b..32445f238 100644 --- a/src/Makefile +++ b/src/Makefile @@ -408,7 +408,7 @@ noopt: $(MAKE) OPTIMIZATION="-O0" valgrind: - $(MAKE) OPTIMIZATION="-O0" MALLOC="libc" CFLAGS="-DSANITIZE" CXXFLAGS="-DSANITIZE" + $(MAKE) OPTIMIZATION="-O0" USEASM="false" MALLOC="libc" CFLAGS="-DSANITIZE" CXXFLAGS="-DSANITIZE" helgrind: $(MAKE) OPTIMIZATION="-O0" MALLOC="libc" CFLAGS="-D__ATOMIC_VAR_FORCE_SYNC_MACROS" diff --git a/src/ae.cpp b/src/ae.cpp index 7387e2a7f..1a323a7dd 100644 --- a/src/ae.cpp +++ b/src/ae.cpp @@ -294,6 +294,7 @@ int aePostFunction(aeEventLoop *eventLoop, std::function fn, bool fSynch } aeCommand cmd = {}; + memset(&cmd, 0, sizeof(aeCommand)); cmd.op = AE_ASYNC_OP::PostCppFunction; cmd.pfn = new (MALLOC_LOCAL) std::function(fn); cmd.pctl = nullptr; diff --git a/src/db.cpp b/src/db.cpp index 88703cc14..dbb309734 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -1173,6 +1173,7 @@ void moveCommand(client *c) { /* Return zero if the key already exists in the target DB */ if (lookupKeyWrite(dst,c->argv[1]) != NULL) { addReply(c,shared.czero); + decrRefCount(o); return; } dbAdd(dst,c->argv[1],o); diff --git a/src/replication.cpp b/src/replication.cpp index 67a550cf8..dae37fc72 100644 --- a/src/replication.cpp +++ b/src/replication.cpp @@ -2561,7 +2561,7 @@ int slaveTryPartialResynchronization(redisMaster *mi, connection *conn, int read * establish a connection with the master. */ void syncWithMaster(connection *conn) { serverAssert(GlobalLocksAcquired()); - char tmpfile[256], *err = NULL; + char tmpfile[256] = {0}, *err = NULL; int dfd = -1, maxtries = 5; int psync_result;