From 6dfe15ed2e26ff99e513ffedeaaac3f4fe2846cc Mon Sep 17 00:00:00 2001 From: Anthony Fieroni Date: Fri, 13 Dec 2019 18:06:11 +0200 Subject: [PATCH] Fix signed / unsigned compare Signed-off-by: Anthony Fieroni --- src/claimtrie/sqlite.h | 4 ++-- src/txdb.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/claimtrie/sqlite.h b/src/claimtrie/sqlite.h index 8fda04ac7..f309ae822 100644 --- a/src/claimtrie/sqlite.h +++ b/src/claimtrie/sqlite.h @@ -42,7 +42,7 @@ namespace sqlite auto ptr = sqlite3_column_blob(stmt, inx); if (!ptr) return ret; int bytes = sqlite3_column_bytes(stmt, inx); - assert(bytes <= ret.size()); + assert(bytes > 0 && bytes <= int(ret.size())); std::memcpy(ret.begin(), ptr, bytes); return ret; } @@ -52,7 +52,7 @@ namespace sqlite auto ptr = sqlite3_column_blob(stmt, inx); if (!ptr) return ret; int bytes = sqlite3_column_bytes(stmt, inx); - assert(bytes <= ret.size()); + assert(bytes > 0 && bytes <= int(ret.size())); std::memcpy(ret.begin(), ptr, bytes); return ret; } diff --git a/src/txdb.h b/src/txdb.h index 5f41258b7..a70ab9155 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -44,6 +44,7 @@ namespace sqlite { auto ptr = (const unsigned char*)sqlite3_column_blob(stmt, inx); if (!ptr) return {}; int bytes = sqlite3_column_bytes(stmt, inx); + assert(bytes >= 0); return CScript(ptr, ptr + bytes); } @@ -62,7 +63,7 @@ namespace sqlite { uint256 ret; if (!ptr) return ret; int bytes = sqlite3_column_bytes(stmt, inx); - assert(bytes <= ret.size()); + assert(bytes > 0 && bytes <= int(ret.size())); std::memcpy(ret.begin(), ptr, bytes); return ret; }