Commit graph

11861 commits

Author SHA1 Message Date
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
Heiko Lewin
21db0989d7 Merge branch 'debug-fix' into 'master'
Apply small fix that was reported as an issue

Closes #385

See merge request cairo/cairo!105
2021-01-11 19:33:35 +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
9508d25d6a Merge branch 'xml-requires-png' into 'master'
autoconf: Reject --enable-xml --disable-png

See merge request cairo/cairo!87
2021-01-06 21:57:21 +00:00
Uli Schlachter
414d0aee10 Merge branch 'fix-compiler-warnings-in-test-suite' into 'master'
Fix compiler warnings in test suite

See merge request cairo/cairo!98
2021-01-06 13:41:30 +00:00
Uli Schlachter
b80d26a064 Merge branch 'meson-ci-macos' into 'master'
meson: fix macOS build and add macOS ci

Closes #441

See merge request cairo/cairo!101
2021-01-06 13:27:28 +00:00
Tim-Philipp Müller
d8d16562ec meson: fix macOS build and add macOS ci
Fixes #441
2021-01-04 20:08:06 +00:00
Sven Neumann
4e02f705e4 Add tests for PDF metadata
Extend the "pdf-tagged-text" test so that it does some basic checks
on the PDF file it creates. This covers the date fields as well as
some other metadata. More checks can and should be added.
2021-01-04 18:04:27 +01:00
Uli Schlachter
cb3618f76d Merge branch 'fix_memory_allocation' into 'master'
Added checks for failed strdups in cairo-recording-surface.c

See merge request cairo/cairo!99
2021-01-04 15:47:29 +00: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
Sven Neumann
a9ea73ae0c Fix compiler warnings in test suite
Fix some enum mixups, mostly cairo_status_t vs cairo_test_status_t.
2021-01-04 14:08:38 +01:00
Uli Schlachter
b0ef04e2d5 Merge branch 'meson-ci-android' into 'master'
ci: add meson android aarch64 build

See merge request cairo/cairo!96
2021-01-04 12:21:16 +00:00
Tim-Philipp Müller
a7a9c11309 ci: add meson android aarch64 build 2020-12-31 18:48:48 +00:00
Heiko Lewin
0bf2c140d2 Merge branch 'uninitialised-var-in-recording' into 'master'
Fix two uninitialised variables in _cairo_recording_surface_snapshot()

See merge request cairo/cairo!95
2020-12-29 00:03:25 +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
Tim-Philipp Müller
c47db9e36c autotools: dist meson subproject wraps
Fixes #447
2020-12-25 19:48:23 +00: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
979382dd30 Merge branch 'boilerplate-leak' into 'master'
boilerplate-xcb: Avoid leaks on error

See merge request cairo/cairo!82
2020-12-25 14:43:52 +00: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
Uli Schlachter
8d7c08d934 Merge branch 'csi' into 'master'
meson: Generate cairo-script-interpreter.pc needed by GTK+

See merge request cairo/cairo!70
2020-12-23 07:50:03 +00:00
Xavier Claessens
ebbaebdec1 meson: Generate cairo-script-interpreter.pc needed by GTK+ 2020-12-22 13:16:05 -05:00
Uli Schlachter
f271715f37 Replace $have_png with $use_png
The remaining code in configure.ac also uses this variable.

Reported-at: 81102cc214 (note_201221)
Signed-off-by: Uli Schlachter <psychon@znc.in>
2020-12-19 11:24:46 +01:00
Uli Schlachter
a012540d99 autoconf: Reject --enable-xml --disable-png
The xml surface depends on png. Before this commit, configuring with
autogen.sh --disable-png --disable-svg --enable-xml resulted in a
failing build:

src/cairo-xml-surface.c: In function ‘_cairo_xml_emit_image’:
src/cairo-xml-surface.c:673:14: error: implicit declaration of function
‘cairo_surface_write_to_png_stream’

After this commit, configure instead rejects this combination with:

checking whether cairo's xml surface backend feature could be enabled... no (requires --enable-png)
configure: error:  xml surface backend feature could not be enabled

Noticed-at: https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/67#note_644347
Signed-off-by: Uli Schlachter <psychon@znc.in>
2020-12-19 11:10:13 +01:00
Uli Schlachter
8481452510 test/meson.build: Add missing tests
These are entries that are present in test/Makefile.sources, but are
missing from test/meson.build.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2020-12-15 18:59:31 +01:00
Uli Schlachter
3a77858dbd test/Makefile.sources: Use tabs for indentation
Signed-off-by: Uli Schlachter <psychon@znc.in>
2020-12-15 18:59:10 +01:00
Heiko Lewin
0677e0a949 Add meson support 2020-12-15 18:14:35 +01:00
Heiko Lewin
8bc14a6bba Minor cleanups 2020-12-15 17:14:18 +01:00
Heiko Lewin
03a820b173 Fix mask usage in image-compositor 2020-12-15 16:48:19 +01:00
Uli Schlachter
7b258a2fb8 Merge branch 'libversion-fixup-match-autotools' into 'master'
meson: fix library versioning

Closes #442

See merge request cairo/cairo!84
2020-12-15 15:17:39 +00:00
Tim-Philipp Müller
e9ccb1d8d0 meson: fix library versioning
Fixes #442
2020-12-15 00:22:37 +00:00
Uli Schlachter
e22d7212ac Merge branch 'bigsur-use-after-free' into 'master'
Ref and destroy the cairo surface handed off to CoreGraphics.

Closes #420

See merge request cairo/cairo!52
2020-12-11 14:14:24 +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
Uli Schlachter
2ceb279d70 boilerplate-xcb: Avoid leaks on success
This gets rid of the following two leaks reported by valgrind when successfully
running a test with CAIRO_TEST_TARGET=xcb:

8,000 bytes in 2 blocks are definitely lost in loss record 9 of 10
   at 0x483877F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x4B7E135: read_packet (xcb_in.c:259)
   by 0x4B7E135: _xcb_in_read (xcb_in.c:1031)
   by 0x4B7BF8E: _xcb_conn_wait (xcb_conn.c:516)
   by 0x4B7D6AE: wait_for_reply (xcb_in.c:516)
   by 0x4B7D8C8: xcb_request_check (xcb_in.c:745)
   by 0x18D747: _cairo_boilerplate_xcb_create_surface (cairo-boilerplate-xcb.c:310)
   by 0x12906F: cairo_test_for_target (cairo-test.c:819)
   by 0x12AAB5: _cairo_test_context_run_for_target (cairo-test.c:1555)
   by 0x126921: _cairo_test_runner_draw (cairo-test-runner.c:250)
   by 0x126921: main (cairo-test-runner.c:932)

8,000 bytes in 2 blocks are definitely lost in loss record 10 of 10
   at 0x483877F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x4B7E135: read_packet (xcb_in.c:259)
   by 0x4B7E135: _xcb_in_read (xcb_in.c:1031)
   by 0x4B7BF8E: _xcb_conn_wait (xcb_conn.c:516)
   by 0x4B7D6AE: wait_for_reply (xcb_in.c:516)
   by 0x4B7D7C0: xcb_wait_for_reply (xcb_in.c:546)
   by 0x18D45D: find_depth (cairo-boilerplate-xcb.c:154)
   by 0x18D45D: _cairo_boilerplate_xcb_create_render_0_0 (cairo-boilerplate-xcb.c:621)
   by 0x12906F: cairo_test_for_target (cairo-test.c:819)
   by 0x12AAB5: _cairo_test_context_run_for_target (cairo-test.c:1555)
   by 0x126921: _cairo_test_runner_draw (cairo-test-runner.c:250)
   by 0x126921: main (cairo-test-runner.c:932)

Signed-off-by: Uli Schlachter <psychon@znc.in>
2020-12-05 08:08:14 +01:00
Uli Schlachter
e3eaccb939 boilerplate-xcb: Avoid leaks on error
Before this commit, running the test suite against a non-existing
display under valgrind resulted in:

$ ( cd test; DISPLAY=:2 CAIRO_TEST_TARGET=xcb valgrind --leak-check=full .libs/cairo-test-suite -f random-clip )
[...]
==47359== 64 bytes in 2 blocks are definitely lost in loss record 1 of 7
==47359==    at 0x483AB65: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==47359==    by 0x18A272: cairo_boilerplate_xcalloc (cairo-boilerplate-system.c:65)
==47359==    by 0x18D652: _cairo_boilerplate_xcb_create_surface (cairo-boilerplate-xcb.c:269)
==47359==    by 0x12906F: cairo_test_for_target (cairo-test.c:819)
==47359==    by 0x12AAB5: _cairo_test_context_run_for_target (cairo-test.c:1555)
==47359==    by 0x126921: _cairo_test_runner_draw (cairo-test-runner.c:250)
==47359==    by 0x126921: main (cairo-test-runner.c:932)

This commit fixes that by freeing the allocated memory in the error
path.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2020-12-05 07:46:41 +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
Bryce Harrington
dfbc57f9a3 build: Update ssh url for cairographics.org 2020-11-27 18:18:03 -08:00