Skip to content

Commit

Permalink
More memory bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tranz5 committed May 20, 2014
1 parent 4650538 commit c8cbded
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,8 @@ bool CAddrDB::Read(CAddrMan& addr)
// use file size to size memory buffer
int fileSize = GetFilesize(filein);
int dataSize = fileSize - sizeof(uint256);
//Don't try to resize to a negative number if file is small
if ( dataSize < 0 ) dataSize = 0;
vector<unsigned char> vchData;
vchData.resize(dataSize);
uint256 hashIn;
Expand Down
4 changes: 4 additions & 0 deletions src/key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,10 @@ bool CKey::SignCompact(uint256 hash, std::vector<unsigned char>& vchSig)
}

if (nRecId == -1)
{
ECDSA_SIG_free(sig);
throw key_error("CKey::SignCompact() : unable to construct recoverable key");
}

vchSig[0] = nRecId+27+(fCompressedPubKey ? 4 : 0);
BN_bn2bin(sig->r,&vchSig[33-(nBitsR+7)/8]);
Expand Down Expand Up @@ -367,6 +370,7 @@ bool CKey::SetCompactSignature(uint256 hash, const std::vector<unsigned char>& v
ECDSA_SIG_free(sig);
return true;
}
ECDSA_SIG_free(sig);
return false;
}

Expand Down

0 comments on commit c8cbded

Please sign in to comment.