Skip to content

Commit cd7e6d8

Browse files
committed
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.
1 parent 6ac7541 commit cd7e6d8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

storage/archive/ha_archive.cc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,27 @@ unsigned int ha_archive::pack_row_v1(uchar *record)
376376
uchar *pos;
377377
DBUG_ENTER("pack_row_v1");
378378
memcpy(record_buffer->buffer, record, table->s->reclength);
379+
380+
/*
381+
The end of VARCHAR fields are filled with garbage,so here
382+
we explicitly set the end of the VARCHAR fields with zeroes
383+
*/
384+
385+
for (Field** field= table->field; (*field) ; field++)
386+
{
387+
Field *fld= *field;
388+
if (fld->type() == MYSQL_TYPE_VARCHAR)
389+
{
390+
if (!(fld->is_real_null(record - table->record[0])))
391+
{
392+
ptrdiff_t start= (fld->ptr - table->record[0]);
393+
Field_varstring *const field_var= (Field_varstring *)fld;
394+
uint offset= field_var->data_length() + field_var->length_size();
395+
memset(record_buffer->buffer + start + offset, 0,
396+
fld->field_length - offset + 1);
397+
}
398+
}
399+
}
379400
pos= record_buffer->buffer + table->s->reclength;
380401
for (blob= table->s->blob_field, end= blob + table->s->blob_fields;
381402
blob != end; blob++)

0 commit comments

Comments
 (0)