[cairo] Copy of path in cairo 1.4.10

Fred Kiefer fredkiefer at gmx.de
Mon Oct 1 09:11:42 PDT 2007

As you may remember, I am the maintainer of the cairo backend for
GNUstep, that is we use cairo to generate our output. This backend is
still experimental but becoming more and more popular.
Now over the last few weeks there have been reoccurring error reports on
problems when using the cairo function  cairo_copy_path() with cairo
1.4.10. Just today I switched to this cairo release myself and could
reproduce the problem. It turns out that the functions used in
cairo_path.c to copy the path complains if the given path has no
elements. As I could not find a way to determine if the current path
isn't empty, I need to copy the path in any case. My workaround now is
to ignore the return value of this function call.

Perhaps it would be possible to come up with a special error value for
this case or even not report it as an error.

Here the offending function:

static cairo_path_t *
_cairo_path_create_internal (cairo_path_fixed_t *path_fixed,
			     cairo_gstate_t     *gstate,
			     cairo_bool_t	 flatten)
    cairo_path_t *path;

    path = malloc (sizeof (cairo_path_t));
    if (path == NULL)
	return (cairo_path_t*) &_cairo_path_nil;

    path->num_data = _cairo_path_count (path, path_fixed,
					_cairo_gstate_get_tolerance (gstate),
    if (path->num_data <= 0) {
	free (path);
	return (cairo_path_t*) &_cairo_path_nil;

    path->data = malloc (path->num_data * sizeof (cairo_path_data_t));
    if (path->data == NULL) {
	free (path);
	return (cairo_path_t*) &_cairo_path_nil;

    path->status = _cairo_path_populate (path, path_fixed,
			                 gstate, flatten);

    return path;

As you can see it tests for "<= 0".


More information about the cairo mailing list