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

Uli Schlachter <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
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 <[email protected]>
> 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
> <[email protected]>
> 
> 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.
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.