diff options
Diffstat (limited to 'sql/session_tracker.cc')
-rw-r--r-- | sql/session_tracker.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sql/session_tracker.cc b/sql/session_tracker.cc index 45d7db91fb4..1b21012f09e 100644 --- a/sql/session_tracker.cc +++ b/sql/session_tracker.cc @@ -1221,7 +1221,7 @@ void Session_tracker::store(THD *thd, String *buf) } size_t length= buf->length() - start; - uchar *data= (uchar *)(buf->ptr() + start); + uchar *data; uint size; if ((size= net_length_size(length)) != 1) @@ -1231,8 +1231,16 @@ void Session_tracker::store(THD *thd, String *buf) buf->length(start); // it is safer to have 0-length block in case of error return; } + + /* + The 'buf->reserve()' can change the buf->ptr() so we cannot + calculate the 'data' earlier. + */ + data= (uchar *)(buf->ptr() + start); memmove(data + (size - 1), data, length); } + else + data= (uchar *)(buf->ptr() + start); net_store_length(data - 1, length); } |