[Mesa-dev] [PATCH] Fix zero-division in llvmpipe_texture_layout()

Roland Scheidegger sroland at vmware.com
Tue Jun 10 06:23:55 PDT 2014


Am 07.06.2014 20:38, schrieb Johannes Obermayr:
> From: Takashi Iwai <tiwai at suse.de>
> 
> Fix the crash of "gnome-control-center info" invocation on QEMU where
> zero height is passed at init.
> 
> Fixes: https://bugzilla.novell.com/show_bug.cgi?id=879462
> 
> Signed-off-by: Takashi Iwai <tiwai at suse.de>
> ---
> To: mesa-dev at lists.freedesktop.org
> Cc: "10.2" <mesa-stable at lists.freedesktop.org>
> Takashi: Please send also a proper patch to mesa-dev and mesa-stable next time ...
> ---
>  src/gallium/drivers/llvmpipe/lp_texture.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
> index f601181..5ab2559 100644
> --- a/src/gallium/drivers/llvmpipe/lp_texture.c
> +++ b/src/gallium/drivers/llvmpipe/lp_texture.c
> @@ -115,7 +115,7 @@ llvmpipe_texture_layout(struct llvmpipe_screen *screen,
>              lpr->row_stride[level] = align(nblocksx * block_size, util_cpu_caps.cacheline);
>  
>           /* if row_stride * height > LP_MAX_TEXTURE_SIZE */
> -         if (lpr->row_stride[level] > LP_MAX_TEXTURE_SIZE / nblocksy) {
> +         if (nblocksy && lpr->row_stride[level] > LP_MAX_TEXTURE_SIZE / nblocksy) {
>              /* image too large */
>              goto fail;
>           }
> 

I am sort of surprised zero sized textures don't crash elsewhere (we
should always allocate at least 64 bytes but I wouldn't really trust
texture wrapping code to work later) but this looks good to me. I guess
it could be alternatively more simply written as
(uint64_t)lpr->row_stride[level] * nblocksy > LP_MAX_TEXTURE_SIZE
but either way is fine by me.

Reviewed-by: Roland Scheidegger <sroland at vmware.com>


More information about the mesa-dev mailing list