mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Add DBUG_ASSERT in Field::ptr_in_record
1. Subtracting table->record[0] from record is UB (non-contiguous buffers) 2. It is very popular to use move_field_offset, which changes Field::ptr, but leaves table->record[0] unchanged. This makes a ptr_in_record result incorrect, since it relies on table->record[0] value. The check ensures the result is within the queried record boundaries.
This commit is contained in:
@@ -1151,8 +1151,9 @@ public:
|
||||
virtual void reset_fields() {}
|
||||
const uchar *ptr_in_record(const uchar *record) const
|
||||
{
|
||||
my_ptrdiff_t l_offset= (my_ptrdiff_t) (record - table->record[0]);
|
||||
return ptr + l_offset;
|
||||
my_ptrdiff_t l_offset= (my_ptrdiff_t) (ptr - table->record[0]);
|
||||
DBUG_ASSERT(l_offset >= 0 && table->s->rec_buff_length - l_offset > 0);
|
||||
return record + l_offset;
|
||||
}
|
||||
virtual int set_default();
|
||||
|
||||
|
Reference in New Issue
Block a user