[PATCH libdrm] xf86drm: Fix operator precedence

Frank Binns frank.binns at imgtec.com
Wed Feb 20 11:59:41 UTC 2019


Reviewed-by: Frank Binns <frank.binns at imgtec.com>

Thierry Reding <thierry.reding at gmail.com> writes:

> From: Thierry Reding <treding at nvidia.com>
>
> The array subscription operator ([]) has higher precedence than the
> indirection operator (*), so we need to use parentheses to properly
> instruct the compiler to dereference the pointer to an array first,
> and then subscript into the array.
>
> Fixes a crash observed on Tegra.
>
> Signed-off-by: Thierry Reding <treding at nvidia.com>
> ---
>  xf86drm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/xf86drm.c b/xf86drm.c
> index d006bb38f800..5de37083c9a3 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -3606,14 +3606,14 @@ static int drmParseOFDeviceInfo(int maj, int min, char ***compatible)
>              free(value);
>          }
>  
> -        *compatible[i] = tmp_name;
> +        (*compatible)[i] = tmp_name;
>      }
>  
>      return 0;
>  
>  free:
>      while (i--)
> -        free(*compatible[i]);
> +        free((*compatible)[i]);
>  
>      free(*compatible);
>      return err;



More information about the dri-devel mailing list