summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml30
-rw-r--r--.gitlab-ci/fedora.Dockerfile2
-rwxr-xr-x.gitlab-ci/run-tests.sh3
-rw-r--r--lsan.supp7
-rw-r--r--meson.build20
-rw-r--r--meson_options.txt12
-rw-r--r--pango/pango-layout.c8
-rw-r--r--tests/test-break.c22
-rw-r--r--tests/test-itemize.c2
-rw-r--r--tests/test-layout.c2
10 files changed, 87 insertions, 21 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5d4a265f..dffa8056 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,5 +1,6 @@
stages:
- build
+ - analysis
- docs
- deploy
@@ -9,8 +10,9 @@ variables:
MESON_TEST_TIMEOUT_MULTIPLIER: 2
linux-fedora:
- image: registry.gitlab.gnome.org/gnome/pango/fedora:v1
+ image: registry.gitlab.gnome.org/gnome/pango/fedora:v2
stage: build
+ needs: []
variables:
EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both"
script:
@@ -31,8 +33,32 @@ linux-fedora:
- "${CI_PROJECT_DIR}/_build/hello.png"
- "${CI_PROJECT_DIR}/_build/fontlist.txt"
+asan-build:
+ image: registry.gitlab.gnome.org/gnome/pango/fedora:v2
+ tags: [ asan ]
+ stage: analysis
+ needs: []
+ variables:
+ script:
+ - CC=clang meson --buildtype=debugoptimized -Db_sanitize=address -Db_lundef=false -Dintrospection=false _build
+ - ninja -C _build
+ - .gitlab-ci/run-tests.sh _build
+ allow_failure: true
+ artifacts:
+ when: always
+ reports:
+ junit:
+ - "${CI_PROJECT_DIR}/_build/report.xml"
+ name: "gtk-${CI_COMMIT_REF_NAME}"
+ paths:
+ - "${CI_PROJECT_DIR}/_build/meson-logs"
+ - "${CI_PROJECT_DIR}/_build/report.xml"
+ - "${CI_PROJECT_DIR}/_build/hello.png"
+ - "${CI_PROJECT_DIR}/_build/fontlist.txt"
+
msys2-mingw64:
stage: build
+ needs: []
tags:
- win32-ps
variables:
@@ -54,6 +80,7 @@ msys2-mingw64:
reference:
image: registry.gitlab.gnome.org/gnome/pango/fedora:v1
stage: docs
+ needs: []
variables:
EXTRA_MESON_FLAGS: ""
script:
@@ -67,6 +94,7 @@ reference:
pages:
stage: deploy
+ needs: ['reference']
script:
- mv _reference/ public/
artifacts:
diff --git a/.gitlab-ci/fedora.Dockerfile b/.gitlab-ci/fedora.Dockerfile
index e7ff2feb..f2240cac 100644
--- a/.gitlab-ci/fedora.Dockerfile
+++ b/.gitlab-ci/fedora.Dockerfile
@@ -26,8 +26,10 @@ RUN dnf -y install \
harfbuzz-devel \
hicolor-icon-theme \
itstool \
+ libasan \
lcov \
libthai-devel \
+ libubsan \
libXft-devel \
ninja-build \
python3 \
diff --git a/.gitlab-ci/run-tests.sh b/.gitlab-ci/run-tests.sh
index cca589b4..e5c8e9af 100755
--- a/.gitlab-ci/run-tests.sh
+++ b/.gitlab-ci/run-tests.sh
@@ -6,6 +6,9 @@ set +e
srcdir=$( pwd )
builddir=$1
+# Ignore memory leaks lower in dependencies
+export LSAN_OPTIONS=suppressions=$srcdir/lsan.supp
+
meson test -C ${builddir} \
--print-errorlogs \
--suite=pango
diff --git a/lsan.supp b/lsan.supp
new file mode 100644
index 00000000..06a74df1
--- /dev/null
+++ b/lsan.supp
@@ -0,0 +1,7 @@
+leak:g_quark_init
+leak:libc.so
+leak:libfontconfig.so
+leak:libcairo.so
+leak:libpixman-1.so
+leak:libthai.so
+leak:libdatrie.so
diff --git a/meson.build b/meson.build
index 20f73947..482b0735 100644
--- a/meson.build
+++ b/meson.build
@@ -270,16 +270,24 @@ endif
pango_deps += harfbuzz_dep
# Only use FontConfig fallback when required or requested
-fontconfig_required = (host_system != 'windows' and host_system != 'darwin') or get_option('use_fontconfig')
-fontconfig_dep = dependency('fontconfig', version: fontconfig_req_version, required: false)
+fontconfig_option = get_option('fontconfig')
+
+fontconfig_sys_required = (host_system != 'windows' and host_system != 'darwin')
+if fontconfig_sys_required and fontconfig_option.disabled()
+ error('Fontconfig is required on this platform (pass -Dfontconfig=enabled or -Dfontconfig=auto)')
+endif
+
+fontconfig_required = fontconfig_sys_required or fontconfig_option.enabled()
+
+fontconfig_dep = dependency('fontconfig', version: fontconfig_req_version, required: fontconfig_option)
if fontconfig_dep.found()
fontconfig_pc = 'fontconfig'
else
if cc.get_id() == 'msvc' and cc.has_header('fontconfig/fontconfig.h')
# Look for the Visual Studio-style import library if FontConfig's .pc file cannot be
# found on Visual Studio
- fontconfig_dep = cc.find_library('fontconfig', required: false)
+ fontconfig_dep = cc.find_library('fontconfig', required: fontconfig_option)
if fontconfig_dep.found()
fontconfig_lib = '-lfontconfig'
endif
@@ -312,7 +320,7 @@ message('fontconfig has FcWeightFromOpenTypeDouble: ' + res)
# The first version of freetype with a pkg-config file is 2.1.5
# We require both fontconfig and freetype if we are to have either.
-freetype_dep = dependency('freetype2', required: false)
+freetype_dep = dependency('freetype2', required: get_option('freetype'))
if freetype_dep.found()
freetype2_pc = 'freetype2'
@@ -320,7 +328,7 @@ else
if cc.get_id() == 'msvc' and cc.has_header('ft2build.h')
foreach ft2_lib: ['freetype', 'freetypemt']
if not freetype_dep.found()
- freetype_dep = cc.find_library(ft2_lib, required: false)
+ freetype_dep = cc.find_library(ft2_lib, required: get_option('freetype'))
if freetype_dep.found()
freetype2_lib = '-l@0@'.format(ft2_lib)
endif
@@ -330,7 +338,7 @@ else
endif
if fontconfig_required and not freetype_dep.found()
- freetype_dep = dependency('freetype2', required: false,
+ freetype_dep = dependency('freetype2', required: get_option('freetype'),
fallback: ['freetype2', 'freetype_dep'])
endif
diff --git a/meson_options.txt b/meson_options.txt
index 437ba149..5aa7c795 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -10,10 +10,10 @@ option('install-tests',
description : 'Install tests',
type: 'boolean',
value: 'false')
-option('use_fontconfig',
- description : 'Force using FontConfig where it is optional, on Windows and macOS. This is ignored on platforms where it is required',
- type: 'boolean',
- value: 'false')
+option('fontconfig',
+ description : 'Build with FontConfig support. Passing \'auto\' or \'disabled\' disables fontconfig where it is optional, i.e. on Windows and macOS. Passing \'disabled\' on platforms where fontconfig is required results in error.',
+ type: 'feature',
+ value: 'auto')
option('sysprof',
type : 'feature',
value : 'disabled',
@@ -30,3 +30,7 @@ option('xft',
type : 'feature',
value : 'auto',
description : 'Build with xft support')
+option('freetype',
+ type : 'feature',
+ value : 'auto',
+ description : 'Build with freetype support')
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 7d5b9b10..68ffd190 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -4088,6 +4088,7 @@ process_line (PangoLayout *layout,
static void
get_items_log_attrs (const char *text,
+ int start,
int length,
GList *items,
PangoLogAttr *log_attrs,
@@ -4096,11 +4097,13 @@ get_items_log_attrs (const char *text,
int offset = 0;
GList *l;
- pango_default_break (text, length, NULL, log_attrs, log_attrs_len);
+ pango_default_break (text + start, length, NULL, log_attrs, log_attrs_len);
for (l = items; l; l = l->next)
{
PangoItem *item = l->data;
+ g_assert (item->offset <= start + length);
+ g_assert (item->length <= (start + length) - item->offset);
pango_tailor_break (text + item->offset,
item->length,
@@ -4371,7 +4374,8 @@ pango_layout_check_lines (PangoLayout *layout)
apply_attributes_to_items (state.items, shape_attrs);
- get_items_log_attrs (start,
+ get_items_log_attrs (layout->text,
+ start - layout->text,
delimiter_index + delim_len,
state.items,
layout->log_attrs + start_offset,
diff --git a/tests/test-break.c b/tests/test-break.c
index db944fbb..c4359643 100644
--- a/tests/test-break.c
+++ b/tests/test-break.c
@@ -62,7 +62,6 @@ test_file (const gchar *filename, GString *string)
length = strlen (test);
len = g_utf8_strlen (test, -1) + 1;
- attrs = g_new (PangoLogAttr, len);
pango_parse_markup (test, -1, 0, &attributes, &text, NULL, &error);
g_assert_no_error (error);
@@ -79,6 +78,10 @@ test_file (const gchar *filename, GString *string)
g_test_skip (msg);
g_free (msg);
#endif
+ g_free (contents);
+ g_object_unref (layout);
+ pango_attr_list_unref (attributes);
+ g_free (text);
return FALSE;
}
@@ -225,6 +228,7 @@ test_file (const gchar *filename, GString *string)
g_object_unref (layout);
g_free (attrs);
g_free (contents);
+ g_free (text);
pango_attr_list_unref (attributes);
return TRUE;
@@ -255,7 +259,7 @@ test_break (gconstpointer d)
GString *dump;
gchar *diff;
- const char *old_locale = setlocale (LC_ALL, NULL);
+ char *old_locale = g_strdup (setlocale (LC_ALL, NULL));
setlocale (LC_ALL, "en_US.utf8");
if (strstr (setlocale (LC_ALL, NULL), "en_US") == NULL)
{
@@ -265,20 +269,26 @@ test_break (gconstpointer d)
g_test_skip (msg);
g_free (msg);
#endif
+ g_free (old_locale);
return;
}
- expected_file = get_expected_filename (filename);
-
dump = g_string_sized_new (0);
if (!test_file (filename, dump))
- return;
+ {
+ g_free (old_locale);
+ g_string_free (dump, TRUE);
+ return;
+ }
+
+ expected_file = get_expected_filename (filename);
diff = diff_with_file (expected_file, dump->str, dump->len, &error);
g_assert_no_error (error);
setlocale (LC_ALL, old_locale);
+ g_free (old_locale);
if (diff && diff[0])
{
@@ -294,9 +304,9 @@ test_break (gconstpointer d)
g_test_fail ();
g_strfreev (lines);
- g_free (diff);
}
+ g_free (diff);
g_string_free (dump, TRUE);
g_free (expected_file);
}
diff --git a/tests/test-itemize.c b/tests/test-itemize.c
index cd145e40..b22f3c2f 100644
--- a/tests/test-itemize.c
+++ b/tests/test-itemize.c
@@ -277,9 +277,9 @@ test_itemize (gconstpointer d)
g_test_fail ();
g_strfreev (lines);
- g_free (diff);
}
+ g_free (diff);
g_string_free (dump, TRUE);
g_free (expected_file);
}
diff --git a/tests/test-layout.c b/tests/test-layout.c
index 0506acd8..a5b6d279 100644
--- a/tests/test-layout.c
+++ b/tests/test-layout.c
@@ -347,9 +347,9 @@ test_layout (gconstpointer d)
g_test_fail ();
g_strfreev (lines);
- g_free (diff);
}
+ g_free (diff);
g_string_free (dump, TRUE);
g_free (expected_file);
}