mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-19 22:11:04 +01:00
hb_shape_justify() copies the buffer text so it can reshape while solving for the axis value, but only the solver path at the end frees the copy. The three "nothing to solve" success returns (default advance already in range, maximum expansion still short of the target, maximum shrink still above it) and the three shaping failure returns leak it, so ordinary line justification leaks one text copy per call. Free it with a scope guard right after the allocation, as the rest of the tree does, and drop the explicit free at the end. Reproduced with leaks --atExit on a plain experimental-API build: four calls on Estedad-VF.ttf give four ROOT LEAKs at hb-shape.cc:319, none with the fix. Add test-shape-justify.c covering all five paths under the experimental-API test list so the asan-ubsan job runs it under LeakSanitizer. The full ASan+UBSan Meson suite passes (289 ok, 2 skipped). Assisted-by: Claude
194 lines
4.5 KiB
Meson
194 lines
4.5 KiB
Meson
if conf.get('HAVE_GLIB', 0) == 0
|
|
message('You need to have glib support enabled to run test/api tests')
|
|
subdir_done()
|
|
endif
|
|
|
|
tests = [
|
|
'test-aat-layout.c',
|
|
'test-baseline.c',
|
|
'test-base-minmax.c',
|
|
'test-be-glyph-advance.c',
|
|
'test-be-num-glyphs.c',
|
|
'test-be-subset-tables.c',
|
|
'test-blob.c',
|
|
'test-buffer.c',
|
|
'test-c.c',
|
|
'test-collect-unicodes.c',
|
|
'test-cplusplus.cc',
|
|
'test-common.c',
|
|
'test-draw.c',
|
|
'test-draw-varc.c',
|
|
'test-extents.c',
|
|
'test-face.c',
|
|
'test-font.c',
|
|
'test-font-scale.c',
|
|
'test-get-table-tags.c',
|
|
'test-glyph-names.c',
|
|
'test-instance-cff2.c',
|
|
'test-map.c',
|
|
'test-object.c',
|
|
'test-ot-alternates.c',
|
|
'test-ot-collect-glyphs.c',
|
|
'test-ot-color.c',
|
|
'test-ot-face.c',
|
|
'test-ot-fetch.c',
|
|
'test-ot-glyphname.c',
|
|
'test-ot-layout.c',
|
|
'test-ot-ligature-carets.c',
|
|
'test-ot-name.c',
|
|
'test-ot-nullable-output.c',
|
|
'test-ot-math.c',
|
|
'test-ot-meta.c',
|
|
'test-ot-metrics.c',
|
|
'test-ot-tag.c',
|
|
'test-ot-extents-cff.c',
|
|
'test-ot-metrics-tt-var.c',
|
|
'test-paint.c',
|
|
'test-subset-repacker.c',
|
|
'test-set.c',
|
|
'test-shape.c',
|
|
'test-shape-plan.c',
|
|
'test-style.c',
|
|
'test-subset.c',
|
|
'test-subset-avar2.c',
|
|
'test-subset-cmap.c',
|
|
'test-subset-drop-tables.c',
|
|
'test-subset-glyf.c',
|
|
'test-subset-hdmx.c',
|
|
'test-subset-hmtx.c',
|
|
'test-subset-nameids.c',
|
|
'test-subset-os2.c',
|
|
'test-subset-post.c',
|
|
'test-subset-vmtx.c',
|
|
'test-subset-cff1.c',
|
|
'test-subset-cff2.c',
|
|
'test-subset-gvar.c',
|
|
'test-subset-hvar.c',
|
|
'test-subset-vvar.c',
|
|
'test-subset-varc.c',
|
|
'test-subset-sbix.c',
|
|
'test-subset-gpos.c',
|
|
'test-subset-math.c',
|
|
'test-subset-colr.c',
|
|
'test-subset-cbdt.c',
|
|
'test-unicode.c',
|
|
'test-var-coords.c',
|
|
'test-version.c',
|
|
]
|
|
|
|
if conf.get('HAVE_FREETYPE', 0) == 1
|
|
tests += [
|
|
'test-ft.c',
|
|
]
|
|
endif
|
|
|
|
if conf.get('HAVE_GRAPHITE2', 0) == 1
|
|
tests += 'test-graphite2.c'
|
|
endif
|
|
|
|
if conf.get('HAVE_CORETEXT', 0) == 1
|
|
tests += [
|
|
'test-coretext.c',
|
|
]
|
|
endif
|
|
|
|
if conf.get('HAVE_DIRECTWRITE', 0) == 1
|
|
tests += [
|
|
'test-directwrite.cc',
|
|
]
|
|
endif
|
|
|
|
if conf.get('HAVE_CAIRO', 0) == 1
|
|
tests += 'test-cairo.c'
|
|
endif
|
|
|
|
if conf.get('HAVE_PTHREAD', 0) == 1
|
|
tests += 'test-multithread.c'
|
|
endif
|
|
|
|
if conf.get('HB_EXPERIMENTAL_API', 0) == 1
|
|
tests += 'test-ot-depend.c'
|
|
tests += 'test-shape-justify.c'
|
|
endif
|
|
|
|
# Default test running environment
|
|
env = environment()
|
|
env.set('MALLOC_CHECK_', '1')
|
|
env.set('G_DEBUG', 'gc-friendly')
|
|
env.set('G_TEST_SRCDIR', meson.current_source_dir())
|
|
env.set('G_TEST_BUILDDIR', meson.current_build_dir())
|
|
|
|
foreach source : tests
|
|
cpp_args = []
|
|
test_name = source.split('.')[0]
|
|
|
|
deps = [libharfbuzz_dep,
|
|
libharfbuzz_cairo_dep,
|
|
libharfbuzz_icu_dep]
|
|
suite = ['api']
|
|
if test_name.contains('-subset') or test_name.contains('-instance') or test_name.contains('-depend')
|
|
if get_option('subset').disabled()
|
|
continue
|
|
endif
|
|
deps += libharfbuzz_subset_dep
|
|
suite += 'subset'
|
|
endif
|
|
|
|
if test_name.contains('-instance') or test_name.contains('-justify')
|
|
cpp_args += '-DHB_EXPERIMENTAL_API'
|
|
endif
|
|
|
|
test(test_name, executable(test_name, source,
|
|
cpp_args: cpp_args,
|
|
include_directories: [incconfig],
|
|
dependencies: deps,
|
|
install: false,
|
|
),
|
|
protocol: 'tap',
|
|
env: env,
|
|
suite: suite)
|
|
endforeach
|
|
|
|
if get_option('harfrust').enabled()
|
|
harfrust_shape_env = environment()
|
|
harfrust_shape_env.set('MALLOC_CHECK_', '1')
|
|
harfrust_shape_env.set('G_DEBUG', 'gc-friendly')
|
|
harfrust_shape_env.set('G_TEST_SRCDIR', meson.current_source_dir())
|
|
harfrust_shape_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
|
|
harfrust_shape_env.set('HB_SHAPER_LIST', 'harfrust')
|
|
|
|
test('test-shape-harfrust',
|
|
executable('test-shape-harfrust', 'test-shape.c',
|
|
include_directories: [incconfig],
|
|
dependencies: [libharfbuzz_dep, libharfbuzz_cairo_dep, libharfbuzz_icu_dep],
|
|
install: false,
|
|
),
|
|
protocol: 'tap',
|
|
env: harfrust_shape_env,
|
|
suite: ['api', 'harfrust'])
|
|
endif
|
|
|
|
if not get_option('raster').disabled()
|
|
test('test-raster',
|
|
executable('test-raster', 'test-raster.cc',
|
|
include_directories: [incconfig],
|
|
dependencies: [libharfbuzz_raster_dep],
|
|
install: false,
|
|
),
|
|
protocol: 'tap',
|
|
env: env,
|
|
suite: ['api', 'raster'])
|
|
endif
|
|
|
|
if not get_option('gpu').disabled()
|
|
test('test-gpu',
|
|
executable('test-gpu', 'test-gpu.cc',
|
|
include_directories: [incconfig],
|
|
dependencies: [libharfbuzz_gpu_dep],
|
|
install: false,
|
|
),
|
|
protocol: 'tap',
|
|
env: env,
|
|
suite: ['api', 'gpu'])
|
|
endif
|