Commit cd7e6d8b authored by Varun Gupta's avatar Varun Gupta

MDEV-11645: archive.archive fails in buildbot with valgrind (Use of uninitialised value)

The fix is about filling the space beyond the end of VARCHAR values with zeroes.
VARCHAR NULLs already has its buffer filled with zeros. So when the VARCHAR fields
are not NULL, then we explicitly fill the buffer with zeros.
parent 6ac75416
......@@ -376,6 +376,27 @@ unsigned int ha_archive::pack_row_v1(uchar *record)
uchar *pos;
DBUG_ENTER("pack_row_v1");
memcpy(record_buffer->buffer, record, table->s->reclength);
/*
The end of VARCHAR fields are filled with garbage,so here
we explicitly set the end of the VARCHAR fields with zeroes
*/
for (Field** field= table->field; (*field) ; field++)
{
Field *fld= *field;
if (fld->type() == MYSQL_TYPE_VARCHAR)
{
if (!(fld->is_real_null(record - table->record[0])))
{
ptrdiff_t start= (fld->ptr - table->record[0]);
Field_varstring *const field_var= (Field_varstring *)fld;
uint offset= field_var->data_length() + field_var->length_size();
memset(record_buffer->buffer + start + offset, 0,
fld->field_length - offset + 1);
}
}
}
pos= record_buffer->buffer + table->s->reclength;
for (blob= table->s->blob_field, end= blob + table->s->blob_fields;
blob != end; blob++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment