[Spice-devel] [spice-common] Fix type of SpiceCursorHeader::type

Christophe Fergeau cfergeau at redhat.com
Thu Sep 13 11:05:13 PDT 2012


On Thu, Sep 13, 2012 at 05:53:39PM +0200, Christophe Fergeau wrote:
> In spice.proto it's defined as enum8 cursor_type type;, which means
> it's demarshalled as an uint8_t.
> This caused valgrind warnings about using uninitialized memory
> during a connection to a VM with remote-viewer

Forget the valgrind part of the explanation, I misinterpreted things ;)
The generated demarshalling code does:
out->cursor.header.type = consume_uint8(&in);
so the full 16 bit of header.type will be initialized.
Similarly, the marshalling code does:
spice_marshaller_add_uint8(m, src->cursor.header.type);
which should be fine as well.
The valgrind warning I was seeing was due to accessing these
fields when the message flags indicates they are not valid.

All in all, this patch will not fix an actual issue, but makes draw.h more
consistent with the .proto file.

Christophe

> ---
>  common/draw.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/draw.h b/common/draw.h
> index 3704358..00057eb 100644
> --- a/common/draw.h
> +++ b/common/draw.h
> @@ -286,7 +286,7 @@ typedef struct SpiceText {
>  
>  typedef struct SpiceCursorHeader {
>      uint64_t unique;
> -    uint16_t type;
> +    uint8_t  type;
>      uint16_t width;
>      uint16_t height;
>      uint16_t hot_spot_x;
> -- 
> 1.7.11.4
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20120913/342ca59b/attachment.pgp>


More information about the Spice-devel mailing list