From 95294e25ea05ea8eeada908a99df81a48f9d3189 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 21 Aug 2020 10:22:23 +0930 Subject: [PATCH] wallet: do valgrind checks when binding db statements. Otherwise valgrind gets upset when we *run* the statements: better to get a backtrace when we bind, so we can tell which field it is! Signed-off-by: Rusty Russell --- wallet/db.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wallet/db.c b/wallet/db.c index 0c1560e1b..313e5671c 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -1319,12 +1320,14 @@ void db_bind_null(struct db_stmt *stmt, int pos) void db_bind_int(struct db_stmt *stmt, int pos, int val) { assert(pos < tal_count(stmt->bindings)); + memcheck(&val, sizeof(val)); stmt->bindings[pos].type = DB_BINDING_INT; stmt->bindings[pos].v.i = val; } void db_bind_u64(struct db_stmt *stmt, int pos, u64 val) { + memcheck(&val, sizeof(val)); assert(pos < tal_count(stmt->bindings)); stmt->bindings[pos].type = DB_BINDING_UINT64; stmt->bindings[pos].v.u64 = val; @@ -1334,7 +1337,7 @@ void db_bind_blob(struct db_stmt *stmt, int pos, const u8 *val, size_t len) { assert(pos < tal_count(stmt->bindings)); stmt->bindings[pos].type = DB_BINDING_BLOB; - stmt->bindings[pos].v.blob = val; + stmt->bindings[pos].v.blob = memcheck(val, len); stmt->bindings[pos].len = len; }