summaryrefslogtreecommitdiff
path: root/storage/archive
diff options
context:
space:
mode:
authorVarun Gupta <varunraiko1803@gmail.com>2017-03-15 21:26:39 +0530
committerVarun Gupta <varunraiko1803@gmail.com>2017-03-15 21:26:39 +0530
commitcd7e6d8b53ac0f9eb75c928b91e941fe70b88d63 (patch)
tree615f7273b48c1dafb62b97459dbef24465123294 /storage/archive
parent6ac754163c417b907ce93ce2e0dd52d8d3cd35b8 (diff)
downloadmariadb-git-cd7e6d8b53ac0f9eb75c928b91e941fe70b88d63.tar.gz
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.
Diffstat (limited to 'storage/archive')
-rw-r--r--storage/archive/ha_archive.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc
index 9d6d100c1b8..810c0fd9c4d 100644
--- a/storage/archive/ha_archive.cc
+++ b/storage/archive/ha_archive.cc
@@ -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++)