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 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?

> In some cases we dont need that at all and dont wanna have the
> burden of maintaining that return structure, so allow that to
> be skiped by just passing a null pointer.
> 
> Signed-off-by: Enrico Weigelt, metux IT consult <[email protected]>
> ---
>  src/cairo-path-fixed.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
> index ac44bb7..36c332f 100644
> --- a/src/cairo-path-fixed.c
> +++ b/src/cairo-path-fixed.c
> @@ -1203,6 +1203,9 @@ _canonical_box (cairo_box_t *box,
>  		const cairo_point_t *p1,
>  		const cairo_point_t *p2)
>  {
> +    if (box == NULL)
> +	return;
> +
>      if (p1->x <= p2->x) {
>  	box->p1.x = p1->x;
>  	box->p2.x = p2->x;
> 


-- 
A normal person is just someone you don't know well enough yet.
 - Nettie Wiebe
-- 
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.