[Mesa-dev] [PATCH] gallium/aux../util: Make u_prims_for_vertices() safe

Marek Olšák maraeo at gmail.com
Wed Dec 9 13:52:10 PST 2015


Pushed, thanks.

Marek

On Wed, Dec 9, 2015 at 10:07 AM, Edward O'Callaghan
<eocallaghan at alterapraxis.com> wrote:
> Let us avoid trapping in hardware from a SIGFPE and instead
> assert on a zero divisor.
>
> Hint: This can occur if a PIPE_PRIM_? is not handled in
>       u_prim_vertex_count() that results in ' info ' not
>       being initialized in the expected manner.
>
> Further, we also fix a possibly NULL pointer dereference
> from ' info ' being NULL from a u_prim_vertex_count() call.
>
> Signed-off-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
> ---
>  src/gallium/auxiliary/util/u_prim.h | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/gallium/auxiliary/util/u_prim.h b/src/gallium/auxiliary/util/u_prim.h
> index 3668015..a09c315 100644
> --- a/src/gallium/auxiliary/util/u_prim.h
> +++ b/src/gallium/auxiliary/util/u_prim.h
> @@ -145,6 +145,9 @@ u_prims_for_vertices(unsigned prim, unsigned num)
>  {
>     const struct u_prim_vertex_count *info = u_prim_vertex_count(prim);
>
> +   assert(info);
> +   assert(info->incr != 0);
> +
>     if (num < info->min)
>        return 0;
>
> --
> 2.5.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list