[Spice-devel] [PATCH] client: add default_agent_caps

Hans de Goede hdegoede at redhat.com
Tue Aug 31 02:52:12 PDT 2010


Hi,

On 08/31/2010 10:30 AM, Alon Levy wrote:
> diff --git a/client/red_client.cpp b/client/red_client.cpp
> index 6c6e066..e1a322e 100644
> --- a/client/red_client.cpp
> +++ b/client/red_client.cpp
> @@ -75,6 +75,12 @@ private:
>       RedClient&  _client;
>   };
>
> +uint32_t default_agent_caps[] = {
> +    (1<<  VD_AGENT_CAP_MOUSE_STATE) |
> +    (1<<  VD_AGENT_CAP_MONITORS_CONFIG) |
> +    (1<<  VD_AGENT_CAP_REPLY)
> +    };
> +
>   void ClipboardEvent::response(AbstractProcessLoop&  events_loop)
>   {
>       static_cast<RedClient*>(events_loop.get_owner())->send_agent_clipboard();
> @@ -328,8 +334,8 @@ RedClient::RedClient(Application&  application)
>       , _agent_out_msg_pos (0)
>       , _agent_tokens (0)
>       , _agent_timer (new AgentTimer())
> -    , _agent_caps_size(0)
> -    , _agent_caps(NULL)
> +    , _agent_caps_size(sizeof(default_agent_caps)/sizeof(default_agent_caps[0]))
> +    , _agent_caps(default_agent_caps)
>       , _migrate (*this)
>       , _glz_window (0, _glz_debug)
>   {

This won't work, _agent_caps is supposed to be a dynamically allocated
array of uint32_t, and gets cleaned up with delete[], but now
you'll end up passing delete[] the address of an array in the data
segment, which is bad (as in it will crash bad).

Regards,

Hans


More information about the Spice-devel mailing list