Fix signed / unsigned compare

Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
This commit is contained in:
Anthony Fieroni 2019-12-13 18:06:11 +02:00
parent 394f1d6088
commit 38006baf03
2 changed files with 4 additions and 3 deletions

View file

@ -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;
}

View file

@ -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;
}