From 822755a424d0abfa408dc34313f4aca4b816f54f Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 23 May 2017 10:04:14 -0700 Subject: Fix: make CCoinsViewDbCursor::Seek work for missing keys Thanks to Suhas Daftuar for figuring this out. --- src/txdb.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 42dc31760b..76aab23983 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -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; } -- cgit v1.2.3