Commit graph

7596 commits

Author SHA1 Message Date
Heiko Lewin
d49d855819 Merge branch 'win32-get-dc' into 'master'
cairo_win32_surface_get_dc: Return NULL for error surfaces

Closes #405

See merge request cairo/cairo!106
2021-01-19 11:06:44 +00:00
Uli Schlachter
4e2e876be1 'Fix' a NULL pointer 'dereference' in cairo-pdf-surface
The expression &image_surface->base basically just casts the
cairo_image_surface_t* to cairo_surface_t*. However, technically it is a
NULL pointer dereference and UndefinedBehaviorSanitizer flags it as
such:

runtime error: member access within null pointer of type 'cairo_image_surface_t' (aka 'struct _cairo_image_surface')

This commit fixes this by adding a NULL check.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-01-17 20:59:58 +01:00
Uli Schlachter
0224c7802f Merge gitlab.freedesktop.org:pcpenpal/cairo 2021-01-17 08:24:00 +01:00
Uli Schlachter
4258fbd3b7 cairo 1.17.4 release
-----BEGIN PGP SIGNATURE-----
 
 iQJOBAABCgA4FiEEpmEQCz2sHU8srYpU5gOyV4+48PsFAl/Cz0AaHGJyeWNlQGJy
 eWNlaGFycmluZ3Rvbi5vcmcACgkQ5gOyV4+48PtUXxAAnYipgwpcIKWoSt4eP1o/
 SPqeupY0AQUWB8y6xKoAhcBzt/HOQBqMxWo+zJSkIndJMRusezSmnt+qHY1bXGTX
 pqyipyYfSUJnT6BB/iZvwcAPlW2ISLuI85qdW126nKX9jxCx1uTejogGzeLC2nLK
 DucPZ1N7HU87GEc2mcl1aYkwTHp1f4jEQhRFExvCJg9YA3W+SgDQ2XEMEeewqljM
 /AT7tL3yWFCv4OU5ci7qhUZPp9ZgWZ1vc+0zS1MgpVo7XwxUWL+NaCbhbVJoH6Dq
 rwPE+RJOh1zkkatY/jZQYmW65gnqxed7lcUJ8XmRCUQiIQNvKzYApthj1EW4bxV4
 yxz+O6OiHlnnf20IwqAirEeHOUHYwINHVTE/UZovB1pu983iPQztNH9wfSmhDkhj
 MS+mNVyLJc4Jb/UQvLOkDVljuT2tmtOYytSeMb5z0D+EjBPDAnWZk9RV7UouK+nF
 HjuXEC45NEPzD5H4G8R4HZXBlSbV/SuzyS0Ljor8GBSdAJ9Xf6pDojgNCXLzHgny
 byD1j7jB5rqmGfy72IRUtLFqThroEiTaKXPNJ44P9lK/YdpBZfn99BmtLEUETNeM
 enm8ex1CWYrzLlq5UwM/2FYLE6Tiy5AQOqGfcnQpuaEG4qKao5Za7hmUy3yWitfa
 OK/2GwlDbHXfu/Ekg1kzzFk=
 =jna2
 -----END PGP SIGNATURE-----

Merge tag '1.17.4'

cairo 1.17.4 release

We are not quite sure what happened, but the 1.17.4 tag and the master
branch have different Git histories, but the same content. The merge
commits are missing from the history of the tag. This merge is simply
the result of "git merge 1.17.4".

This fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/446
2021-01-16 16:17:46 +01:00
Uli Schlachter
0134ac5a3d cairo_win32_surface_get_dc: Return NULL for error surfaces
Surfaces from _cairo_surface_create_in_error() have no backend. This
commit fixes a NULL pointer dereference in cairo_win32_surface_get_dc().

Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/405
Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-01-13 16:26:18 +01:00
Heiko Lewin
974791b4ee Merge branch 'fix-clear-nothing-to-do' into 'master'
Fix _cairo_surface_paint not setting is_clear

Closes #283

See merge request cairo/cairo!104
2021-01-11 19:48:26 +00:00
Heiko Lewin
e45875142f Merge branch 'snapshot-error-fixes' into 'master'
Slightly improve dealing with error snapshots

See merge request cairo/cairo!92
2021-01-11 19:43:54 +00:00
Heiko Lewin
891468f191 Merge branch 'font-parse-oob' into 'master'
Add a bounds check to cairo_cff_font_read_fdselect()

Closes #451

See merge request cairo/cairo!103
2021-01-11 19:41:24 +00:00
Uli Schlachter
be0f938e4a Apply small fix that was reported as an issue
Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/385
Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-01-11 19:08:02 +01:00
Uli Schlachter
a7c49ec861 Fix _cairo_surface_paint not setting is_clear
In commit 10e58a4a I changed the code in cairo-surface.c to avoid
setting surface->is_clear = FALSE; in some situations where it was not
necessary, because the operation did not actually modify anything (it
returned CAIRO_INT_STATUS_NOTHING_TO_DO). However, that change
accidentally also caused _cairo_surface_paint() not to set
surface->is_clear = TRUE; in similar cases. That was unintended.

This commit fixes that by always setting is_clear = TRUE when necessary,
but keeps the optimisation of not setting is_clear = FALSE when not
necessary.

The connection to the below issue is that the issue happened with
surfaces with width=0. Clearing such a surface with CAIRO_OPERATOR_CLEAR
causes CAIRO_INT_STATUS_NOTHING_TO_DO and thus is_clear = TRUE was not
set. This error was later caught by a failed assertion.

Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/283
Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-01-11 18:37:52 +01:00
Uli Schlachter
66c9911850 Slightly improve dealing with error snapshots
An error in _cairo_surface_snapshot_copy_on_write() results in a
snapshot in an error state and the snapshot's ->target could now point
to a surface from _cairo_surface_create_in_error(). These surfaces e.g.
have ->backend == NULL. Thus, anything looking at ->backend->type now
explodes. This commit deals with two places which caused segfaults in
this situation.

There is no test case for this, because
_cairo_surface_snapshot_copy_on_write() really is not supposed to fail.

Found-while-investigating: https://gitlab.freedesktop.org/cairo/cairo/-/issues/448
Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-01-07 17:27:39 +01:00
Uli Schlachter
b1e81ee98f Add a bounds check to cairo_cff_font_read_fdselect()
The code in cairo-cff-subset.c parses a binary format without seeming to
bother much with verifying the data. The result is that poppler can be
used to cause an out-of-bounds write in cairo_cff_font_read_fdselect()
via a crafted font file. Fix this by adding the needed length check.

The other code in the file also contains lots of similar things. Since I
cannot really fix everything properly, I'll just fix the one instance
that was found by a fuzzer.

No testcase is added, because this depends on a broken font that is
quite large. Adding something this big to the test suite does not seem
sensible.

Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/451
Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-01-07 02:03:55 +01:00
Heiko Lewin
58b5aa2706 Added checks for failed strdups in cairo-recording-surface.c 2021-01-04 16:16:15 +01:00
Heiko Lewin
7ac8220c1f Merge branch 'fix-copy-paste-error-in-recording-surfaces' into 'master'
Fix copying tags in a recording surface

Closes #448

See merge request cairo/cairo!93
2021-01-04 15:12:38 +00:00
Heiko Lewin
ed7e51eb41 Merge branch 'font-oob' into 'master'
Add a bounds check to cairo_cff_parse_charstring()

Closes #444

See merge request cairo/cairo!90
2021-01-04 14:41:12 +00:00
Uli Schlachter
be61878a8e Fix two uninitialised variables in _cairo_recording_surface_snapshot()
Signed-off-by: Uli Schlachter <psychon@znc.in>
2020-12-27 21:35:16 +01:00
Uli Schlachter
a1dc600a07 Fix copying tags in a recording surface
The code was copying from the wrong member of an union. This caused a
huge num_dashes value to be read, which then caused a so large memory
allocation that malloc returned an error.

Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/448
Signed-off-by: Uli Schlachter <psychon@znc.in>
2020-12-26 19:11:31 +01:00
Uli Schlachter
467e7822a9 Add a bounds check to cairo_cff_parse_charstring()
The code in cairo-cff-subset.c parses a binary font format without
seeming to bother much verifying the data. The result is that poppler
can be used to cause an out-of-bounds access in
cairo_cff_parse_charstring() via a crafted font file. Fix this by adding
the needed length check.

The other code in the file also contains lots of similar things. Since I
cannot really fix everything properly, I'll just fix the one instance
that was found by a fuzzer.

No testcase is added, because this depends on a broken font that is
quite large. Adding something this big to the test suite does not seem
sensible.

Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/444
Signed-off-by: Uli Schlachter <psychon@znc.in>
2020-12-25 16:09:19 +01:00
Uli Schlachter
c7b6c073ea Merge branch 'xcb-fix-clip-leak' into 'master'
Fix a leak in cairo-xcb's render compositor

Closes #24

See merge request cairo/cairo!83
2020-12-25 14:43:14 +00:00
Uli Schlachter
78266cc8c0 Merge branch 'fix-437' into 'master'
Fix mask usage in image-compositor

See merge request cairo/cairo!85
2020-12-24 08:33:04 +00:00
Heiko Lewin
03a820b173 Fix mask usage in image-compositor 2020-12-15 16:48:19 +01:00
Tim-Philipp Müller
e9ccb1d8d0 meson: fix library versioning
Fixes #442
2020-12-15 00:22:37 +00:00
John Ralls
dccaa9179b Quartz Better manage acquired/replayed surface. 2020-12-05 11:51:17 -08:00
Uli Schlachter
eb75ce0861 Fix a leak in cairo-xcb's render compositor
The code here temporary replaces extents->clip with another clip to call
a function. Afterwards, it restores the previous copy. The temporary
clip is only freed when it still is pointed to by extents->clip.

This logic is wrong. It is indeed possible that the clip is simplified
and changes. In this case, the original clip is also correctly freed.
However, this still means that we have to clean up and destroy the new
clip. The previous code just leaked it.

This was originally identified by Massimo in [1]. I am just committing
his patch.

[1]: https://bugs.freedesktop.org/show_bug.cgi?id=91267

Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/24
Signed-off-by: Uli Schlachter <psychon@znc.in>
2020-12-05 08:15:34 +01:00
John Ralls
1ddfccca31 Quartz image drawing: Remove containers for cairo_surface_t.
Since we now copy the data that CGImage needs we don't need to
keep the surface around anymore, nor release it or the image in the
DataProviderReleaseCallback.
2020-12-03 13:56:50 -08:00
John Ralls
b5e84a9783 Quartz: Ensure that image data and surface are available to draw.
Snapshot the cairo_surface_t and copy the image data to provide to
the CGDataProvider so that it is independent of the cairo_surface_t's
lifetime.

Closes https://gitlab.freedesktop.org/cairo/cairo/-/issues/420
2020-12-03 10:59:04 -08:00
John Ralls
32c12c617a Ensure _cairo_quartz_surface_create_internal always nulls imageSurfaceEquiv. 2020-11-30 14:10:18 -08:00
Bryce Harrington
156cd3eaae Release 1.17.4 2020-11-27 18:18:03 -08:00
Félix Poisot
9e9081a8f6 The array introduced in bff47b43 isn't cleared on surface finish 2020-11-27 18:18:03 -08:00
Marek Kasik
590122daa8 cff: Allow empty array of operands for certain operators
Operators BlueValues, OtherBlues, FamilyBlues, FamilyOtherBlues,
StemSnapH and StemSnapV have operands of type delta which can be
a number or an array of delta-encoded numbers. This array can be
empty according to freetype developers.
This commit checks whether current operator is among those listed
and permits empty operand in such case.
2020-11-27 18:18:03 -08:00
Sven Neumann
c43ff33c43 Fix conversion from ISO 8601 to PDF date string
The code used to unintentionally drop the minutes from the timezone
offset, see issue #392. This is now fixed.
2020-11-27 18:18:03 -08:00
Félix Poisot
8913b6e2fc The array introduced in bff47b43 isn't cleared on surface finish 2020-11-21 11:58:59 +00:00
Marek Kasik
c86b90a019 cff: Allow empty array of operands for certain operators
Operators BlueValues, OtherBlues, FamilyBlues, FamilyOtherBlues,
StemSnapH and StemSnapV have operands of type delta which can be
a number or an array of delta-encoded numbers. This array can be
empty according to freetype developers.
This commit checks whether current operator is among those listed
and permits empty operand in such case.
2020-11-20 15:39:54 +00:00
Sven Neumann
6eb3c9d364 Fix conversion from ISO 8601 to PDF date string
The code used to unintentionally drop the minutes from the timezone
offset, see issue #392. This is now fixed.
2020-11-20 14:56:48 +00:00
George Matsumura
ed98414686 build: Fix various compiler warnings
This fixes a few compiler warnings that were encountered with gcc 9.3.0.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-11-07 06:45:01 -07:00
Nirbheek Chauhan
618b13c436 meson: Add dependencies to the declared libcairo dep
That way when other projects consume our declared dep, they get
transitive dependencies too based on what features cairo was built
with. Without this, projects that build cairo as a subproject and also
build, say, fontconfig as a subproject will fail to find cairo-ft.h
(etc).
2020-11-04 14:50:52 +05:30
Michal Sudolsky
a67735010d fix double free and failed assertions in cairo_scaled_font_destroy 2020-10-21 11:14:28 +00:00
Xavier Claessens
084404cd15 meson: Use pkgmod.generate() for all cairo pc files
Also override each dependency so they can be used when cairo is used as
subproject.
2020-10-06 10:58:04 -04:00
Tim-Philipp Müller
4ea2991a40 Retire dummy cairo-version.h header to fix meson subproject build
It was originally added to make bisecting easier,
but has outlived its usefuleness now.

Going forward we'll have just a single cairo-version.h
header file, the one with the real version numbers.

This is needed to fix the case where cairo is being
built as a Meson subproject, but also simplifies
things in general.

Fixes #421
2020-09-29 15:50:53 +00:00
Uli Schlachter
3b1bf9d6d3 Fix/silence some warnings in 'make check'
'make check' currently fails with the following in src/test-suite.log
(how can one tell automake not to hide the error message in a file?!?):

FAIL: check-doc-syntax.sh
=========================

Checking documentation for incorrect syntax
./cairo-cogl-surface.c: * cairo_cogl_pipeline_ts. On failure, both pointers will be set to
./cairo-cogl-surface.c:/* Mostly taken from cairo_vg_surface.c */
Error: some function names in the docs are not followed by parentheses.
Fix this by searching for the following regexp in the above files:
	'^[^:]*:[/ ][*]\(\|[ 	].*\)\([^#']\|^\)\<\(cairo_[][<>/0-9a-z_]*\>[^][<>(]\)'
FAIL check-doc-syntax.sh (exit status: 1)

This commit silences that. The fix is likely not correct, but since
these are normal comments and not actual doc comments, it does not
matter much.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2020-09-05 08:57:23 +00:00
George Matsumura
f2cb9ba49a meson: Fix musl build
This constitutes few fixes that are necessary to compile correctly
and reduce errors when using musl libc.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-09-02 10:29:04 +00:00
George Matsumura
e47d0de8d2 cogl: Remove filling with cogl-path
This removes code that uses the cogl-path library, which was not
used except when manually modifying a preprocessor flag. It could
not use path caching, was slightly broken, and all of its
functionality was provided better by different code paths.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:58 -06:00
George Matsumura
ecbd7ed174 cogl: Add new path cache
This redesigns the path cache so that it does not mess with the
context functions, thereby hopefully making it much more resilient
to changes in the rest of cairo that change the way the default
context works. It is also much simpler, and it is anticipated that
it will be more maintainable. Performance in contrast to the old
cache design speeds up most traces in cairo-perf-trace, and slows
down only a lesser few by <20%.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:58 -06:00
George Matsumura
939da43c44 cogl: Add minimal font support
This adds very basic path-based font support to the cogl backend,
improving cairo-perf-trace performance by 6x or more on many traces.
This still is not the most desirable form of font support, which
would resemble the texture-based glyph caching in the gl backend or
use cogl-pango to automatically cache glyphs.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:58 -06:00
George Matsumura
26c7103750 cogl: Fix reference counting bugs
Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:58 -06:00
George Matsumura
20d475042c cogl: Increase reading performance of RGB-only surfaces
This makes it so that RGB24 surfaces are represented in such a way
that does not require expensive format conversions during pixel
packing and unpacking.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:58 -06:00
George Matsumura
4068fe0026 cogl: Support mirroring of gradients if no hardware support exists
This mirrors a linear gradient by dobling its size and reflecting it
in the case that hardware does not support mirrored repeating.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:58 -06:00
George Matsumura
9b07a5379b cogl: Limit size of journal
This makes sure the journal is flushed after it reaches a certain
size, so that very large amounts of memory are not consumed if an
explicit flush is not triggered.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:58 -06:00
George Matsumura
08d6c7de2d cogl: Support source surfaces without an alpha component
This ensures that if the source surface does not have an alpha
component (such as those with format RGB24), it is not blended
as if it does.

Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:58 -06:00
George Matsumura
02371a714e cogl: Improve support for hardware without mirrored repeating
Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
2020-08-25 02:30:58 -06:00