fix valgrind issues reported by Chris Morgan

pull/2/head
weidai 2007-08-13 23:55:05 +00:00
parent 994090ba9c
commit d831dd8e85
3 changed files with 5 additions and 2 deletions

View File

@ -509,6 +509,7 @@ size_t RandomNumberSink::Put2(const byte *begin, size_t length, int messageEnd,
size_t ArraySink::Put2(const byte *begin, size_t length, int messageEnd, bool blocking) size_t ArraySink::Put2(const byte *begin, size_t length, int messageEnd, bool blocking)
{ {
if (m_buf+m_total != begin)
memcpy(m_buf+m_total, begin, STDMIN(length, SaturatingSubtract(m_size, m_total))); memcpy(m_buf+m_total, begin, STDMIN(length, SaturatingSubtract(m_size, m_total)));
m_total += length; m_total += length;
return 0; return 0;

View File

@ -20,6 +20,7 @@ inline void SetWords(word *r, word a, size_t n)
inline void CopyWords(word *r, const word *a, size_t n) inline void CopyWords(word *r, const word *a, size_t n)
{ {
if (r != a)
memcpy(r, a, n*WORD_SIZE); memcpy(r, a, n*WORD_SIZE);
} }

View File

@ -221,6 +221,7 @@ Deflator::Deflator(BufferedTransformation *attachment, int deflateLevel, int log
Deflator::Deflator(const NameValuePairs &parameters, BufferedTransformation *attachment) Deflator::Deflator(const NameValuePairs &parameters, BufferedTransformation *attachment)
: LowFirstBitWriter(attachment) : LowFirstBitWriter(attachment)
, m_deflateLevel(-1)
{ {
InitializeStaticEncoders(); InitializeStaticEncoders();
IsolatedInitialize(parameters); IsolatedInitialize(parameters);