Fix use of gwbuf_length in mxs::Buffer

Backend should use empty() instead of length() to see if the buffer is
empty. The length of a buffer should always be valid to call, even on
empty buffers.
This commit is contained in:
Markus Mäkelä 2019-05-21 12:41:11 +03:00
parent 0c19d1ea03
commit b04415d8da
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
2 changed files with 2 additions and 2 deletions

View File

@ -1099,7 +1099,7 @@ public:
*/
size_t length() const
{
return gwbuf_length(m_pBuffer);
return m_pBuffer ? gwbuf_length(m_pBuffer) : 0;
}
/**

View File

@ -253,7 +253,7 @@ bool Backend::write_stored_command()
mxb_assert(in_use());
bool rval = false;
if (m_pending_cmd.length())
if (!m_pending_cmd.empty())
{
rval = write(m_pending_cmd.release());