[Spice-devel] [PATCH 1/2] server: factor out bitmap_fmt_is_rgb

Marc-André Lureau mlureau at redhat.com
Mon Jul 16 08:40:51 PDT 2012



----- Mensaje original -----
> ---
>  server/red_common.h |   11 +++++++++++
>  server/red_worker.c |   15 +++++++--------
>  2 files changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/server/red_common.h b/server/red_common.h
> index cb7bf71..b9dcd49 100644
> --- a/server/red_common.h
> +++ b/server/red_common.h
> @@ -35,4 +35,15 @@ enum {
>      STREAM_VIDEO_FILTER
>  };
>  
> +static inline int bitmap_fmt_is_rgb(uint8_t fmt)
> +{
> +    static const int BITMAP_FMT_IS_RGB[] = {0, 0, 0, 0, 0, 0, 1, 1,
> 1, 1};
> +
> +    if (fmt >= SPICE_BITMAP_FMT_ENUM_END) {
> +        spice_warning("fmt >= SPICE_BITMAP_FMT_ENUM_END");
> +        return 0;
> +    }
> +    return BITMAP_FMT_IS_RGB[fmt];
> +}

It may still access over the array size. So I would either initialize the array with a fixed size of SPICE_BITMAP_FMT_ENUM_END (good thing imho), or add an additional array size check.

ack otherwise.


More information about the Spice-devel mailing list