Permalink
Browse files

Fix: make CCoinsViewDbCursor::Seek work for missing keys

Thanks to Suhas Daftuar for figuring this out.

Github-Pull: #10445
Rebased-From: 822755a
  • Loading branch information...
1 parent 28b8b8b commit 87a21d5922f3cdc7a7e21090dc7078e0774c1c1f @sipa sipa committed with luke-jr May 23, 2017
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/txdb.cpp
View
@@ -98,7 +98,11 @@ CCoinsViewCursor *CCoinsViewDB::Cursor() const
that restriction. */
i->pcursor->Seek(DB_COINS);
// Cache key of first record
- i->pcursor->GetKey(i->keyTmp);
+ if (i->pcursor->Valid()) {
+ i->pcursor->GetKey(i->keyTmp);
+ } else {
+ i->keyTmp.first = 0; // Make sure Valid() and GetKey() return false
+ }
return i;
}

0 comments on commit 87a21d5

Please sign in to comment.