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.
This commit is contained in:
Varun Gupta 2017-03-15 21:26:39 +05:30
parent 6ac754163c
commit cd7e6d8b53

View File

@ -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++)