Prevent segfault when there's an invalid transaction in mempool

It happened to me when I started the upgraded client while the blockchain was re-indexed.