[cairo] [PATCH 03/41] core: _canonical_box() allow NULL box ptr

Uli Schlachter psychon at znc.in
Sat Dec 12 01:50:12 PST 2015


Am 12.12.2015 um 06:05 schrieb Enrico Weigelt, metux IT consult:
> On 11.12.2015 17:41, Uli Schlachter wrote:
>> Am 10.12.2015 um 23:16 schrieb Enrico Weigelt, metux IT consult:
>>> This function is used by several others which can test pathes
>>> for certain properties (eg. _cairo_path_fixed_is_box()),
>>> but expect a pointer to cairo_box_t, which is passed to
>>> _canonical_box() for filling.
>>
>> Uhm, sorry, but... what?
>>
>> I find two callers. _cairo_path_fixed_is_box() and
>> _cairo_path_fixed_is_stroke_box(). The earlier uses the path's head which is
>> never NULL, the later dereferences the pointer before calling this function.
>>
>> So what does this patch fix / help?
> 
> It's used by one of my subsequent patches:

Ah, thanks for the info. I'd suggest adding "A later patch will use this with a
NULL argument", or something like that.

> commit 3546665856413c89c76407015e9ca45f32b22f75
> Author: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
> Date:   Thu Dec 10 22:05:24 2015 +0100
> 
>     drm/i915: fixed test for whether path is a box
> 
>     cairo_clip_path_t doesn't have an flags field anymore, so we need
>     to fix the test for whether a path is a box.
> 
>     Signed-off-by: Enrico Weigelt, metux IT consult
> <enrico.weigelt at gr13.net>
> 
> diff --git a/src/drm/cairo-drm-i915-surface.c
> b/src/drm/cairo-drm-i915-surface.c
> index bb463d9..50cd5d8 100644
> --- a/src/drm/cairo-drm-i915-surface.c
> +++ b/src/drm/cairo-drm-i915-surface.c
> @@ -1815,7 +1815,7 @@ _clip_get_solitary_path (const cairo_clip_t *clip)
>      cairo_clip_path_t *path = NULL;
> 
>      do {
> -       if ((iter->flags & CAIRO_CLIP_PATH_IS_BOX) == 0) {
> +       if (! _cairo_path_fixed_is_box(iter, NULL)) {
>             if (path != NULL)
>                 return FALSE;
> 

Can't you just use a non-NULL argument here? Or, instead add an explicit NULL
check to _cairo_path_fixed_is_box() so that it does not call _canonical_box() at
all?

Uli
-- 
Bruce Schneier can read and understand Perl programs.


More information about the cairo mailing list