[cairo-bugs] [Bug 74779] Segmentation fault when using a complex path for clip and stroke

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Fri Aug 8 08:51:12 PDT 2014


https://bugs.freedesktop.org/show_bug.cgi?id=74779

--- Comment #8 from Massimo <sixtysix at inwind.it> ---
Re the problem caused by using the difference between ptrs:

initially I thought that the problem was that the difference between
raw pointers to stack/heap allocated objects could exceed
2^31 * sizeof(cairo_bo_event_t) and so not representable as an int.

But reading better the code the problem is that you're computing the
difference between addresses of objects of different types
(cairo_bo_start_event_t and cairo_bo_queue_event_t) using pointers to
another type (cairo_bo_event_t).

When the raw difference is not divisible by 'sizeof(cairo_bo_event_t)'
the result is random.

In C, technically, relational operations between pointers are defined
only for pointers to objects from the same array etc. (in C++ it is
possible to use std::less that hides the magic necessary to make it
well defined).

To be on the safe side you'd better cast the pointers to uintptr_t and
return -1 or 0 or 1 for <, ==, >.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo-bugs/attachments/20140808/61912c8e/attachment.html>


More information about the cairo-bugs mailing list