From b84a892fb2e6ee7fdedd04972e431a1457b7231f Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 10 Nov 2014 18:08:17 +0400 Subject: MDEV-7019 String::chop() is wrong and may potentially crash (MySQL bug#56492) Merging a fix from the upstream. --- sql/sql_string.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sql/sql_string.h') diff --git a/sql/sql_string.h b/sql/sql_string.h index 35398f284ee..1fce3ae6c6f 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -232,7 +232,9 @@ public: */ inline void chop() { - Ptr[str_length--]= '\0'; + str_length--; + Ptr[str_length]= '\0'; + DBUG_ASSERT(strlen(Ptr) == str_length); } inline void free() -- cgit v1.2.1