diff options
author | Javier Celaya <javier.celaya@flexvdi.com> | 2015-07-27 13:27:14 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2015-09-15 17:38:12 +0200 |
commit | 7b146745eed1b4b5719362870576996512f08513 (patch) | |
tree | a3db974f15e280a3218e1214b6b927959f5ed373 /common | |
parent | 449c5da90f6ab65a49139eb6c70be6004eb4ee31 (diff) |
Fix linearization of several marshallers with one item
The linearization optimization that avoids copying only one item must
check that there are no further marshallers in the chain.
Just to be clear, we are trying to marshall a message like this:
message {
uint32 data_size;
uint64 *data[data_size] @marshall;
} SomeData;
Where the data field points to an array in dynamic memory. Marshalling
and demarshalling functions look good. The marshalling function creates
a submarshaller for the data field and links it to the root marshaller.
But when it comes to sending the data through the wire, only the
data_size field gets sent. We have observed that, in
spice_marshaller_linearize, execution enters into the optimization that
avoids copying the data when the root marshaller only has one item, but
it ignores the following marshallers in the list. Checking if there are
more marshallers fixes the problem.
Diffstat (limited to 'common')
-rw-r--r-- | common/marshaller.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/common/marshaller.c b/common/marshaller.c index 55b9d51..cedb321 100644 --- a/common/marshaller.c +++ b/common/marshaller.c @@ -419,7 +419,7 @@ uint8_t *spice_marshaller_linearize(SpiceMarshaller *m, size_t skip_bytes, /* Only supported for root marshaller */ assert(m->data->marshallers == m); - if (m->n_items == 1) { + if (m->n_items == 1 && m->next == NULL) { *free_res = FALSE; if (m->items[0].len <= skip_bytes) { *len = 0; |