Cleared UBsan error using non-null pointer

pull/35/head
Jeffrey Walton 2015-07-17 21:50:47 -04:00
parent 20962b51a0
commit cac038a855
1 changed files with 2 additions and 0 deletions

View File

@ -41,6 +41,7 @@ public:
inline size_t Put(const byte *begin, size_t length) inline size_t Put(const byte *begin, size_t length)
{ {
if(!begin || !length) return length;
size_t l = STDMIN(length, MaxSize()-m_tail); size_t l = STDMIN(length, MaxSize()-m_tail);
if (buf+m_tail != begin) if (buf+m_tail != begin)
memcpy(buf+m_tail, begin, l); memcpy(buf+m_tail, begin, l);
@ -59,6 +60,7 @@ public:
inline size_t Peek(byte *target, size_t copyMax) const inline size_t Peek(byte *target, size_t copyMax) const
{ {
if(!target || !copyMax) return 0;
size_t len = STDMIN(copyMax, m_tail-m_head); size_t len = STDMIN(copyMax, m_tail-m_head);
memcpy(target, buf+m_head, len); memcpy(target, buf+m_head, len);
return len; return len;