commit 3127f937b3ac348e98590fede3efbaef42f93bba Author: Laurynas Biveinis Date: Wed Sep 21 12:33:12 2016 +0300 Merge branch 'bug1626002-5.6' into bug1626002-5.7 diff --git a/storage/innobase/mach/mach0data.cc b/storage/innobase/mach/mach0data.cc index 2d3e673..4477016 100644 --- a/storage/innobase/mach/mach0data.cc +++ b/storage/innobase/mach/mach0data.cc @@ -53,7 +53,18 @@ mach_parse_compressed( /* 0nnnnnnn (7 bits) */ ++*ptr; return(static_cast(val)); - } else if (val < 0xC0) { + } + + /* Workaround GCC bug + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77673: + the compiler moves mach_read_from_4 right to the beginning of the + function, causing and out-of-bounds read if we are reading a short + integer close to the end of buffer. */ +#if defined(__GNUC__) && (__GNUC__ >= 5) && !defined(__clang__) + asm volatile("": : :"memory"); +#endif + + if (val < 0xC0) { /* 10nnnnnn nnnnnnnn (14 bits) */ if (end_ptr >= *ptr + 2) { val = mach_read_from_2(*ptr) & 0x3FFF;