office-gobmx/external/freetype/ubsan.patch
Stephan Bergmann 6838d28ce0 external/freetype: Avoid nullptr-with-offset
> workdir/UnpackedTarball/freetype/src/truetype/ttgxvar.c:967:17: runtime error: applying zero offset to null pointer
>  #0 in ft_var_get_item_delta at workdir/UnpackedTarball/freetype/src/truetype/ttgxvar.c:967:17
>  #1 in tt_hvadvance_adjust at workdir/UnpackedTarball/freetype/src/truetype/ttgxvar.c:1138:13
>  #2 in tt_hadvance_adjust at workdir/UnpackedTarball/freetype/src/truetype/ttgxvar.c:1162:12
>  #3 in tt_face_get_metrics at workdir/UnpackedTarball/freetype/src/sfnt/ttmtx.c:326:11
>  #4 in TT_Get_HMetrics at workdir/UnpackedTarball/freetype/src/truetype/ttgload.c:104:5
>  #5 in tt_get_advances at workdir/UnpackedTarball/freetype/src/truetype/ttdriver.c:269:9
>  #6 in FT_Get_Advance at workdir/UnpackedTarball/freetype/src/base/ftadvanc.c:97:15
>  #7 in af_shaper_get_elem at workdir/UnpackedTarball/freetype/src/autofit/afshaper.c:673:7
>  #8 in af_latin_metrics_check_digits at workdir/UnpackedTarball/freetype/src/autofit/aflatin.c:1105:21
>  #9 in af_latin_metrics_init at workdir/UnpackedTarball/freetype/src/autofit/aflatin.c:1156:7
>  #10 in af_face_globals_get_metrics at workdir/UnpackedTarball/freetype/src/autofit/afglobal.c:462:17
>  #11 in af_loader_load_glyph at workdir/UnpackedTarball/freetype/src/autofit/afloader.c:306:13
>  #12 in af_autofitter_load_glyph at workdir/UnpackedTarball/freetype/src/autofit/afmodule.c:489:13
>  #13 in FT_Load_Glyph at workdir/UnpackedTarball/freetype/src/base/ftobjs.c:978:19
>  #14 in FreetypeFont::GetGlyphOutline(unsigned short, basegfx::B2DPolyPolygon&, bool) const at vcl/unx/generic/glyphs/freetype_glyphcache.cxx:903:19
[...]

during CppunitTest_svx_unit

Change-Id: I6d45ec44006458350629edf06b8ec092a450ea05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132357
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-03-31 15:05:43 +02:00

125 lines
4.9 KiB
Diff

--- src/autofit/afcjk.c
+++ src/autofit/afcjk.c
@@ -843,7 +843,7 @@
{
AF_AxisHints axis = &hints->axis[dim];
AF_Segment segments = axis->segments;
- AF_Segment segment_limit = segments + axis->num_segments;
+ AF_Segment segment_limit = axis->num_segments == 0 ? segments : segments + axis->num_segments;
AF_Direction major_dir = axis->major_dir;
AF_Segment seg1, seg2;
FT_Pos len_threshold;
@@ -1005,7 +1005,7 @@
AF_CJKAxis laxis = &((AF_CJKMetrics)hints->metrics)->axis[dim];
AF_Segment segments = axis->segments;
- AF_Segment segment_limit = segments + axis->num_segments;
+ AF_Segment segment_limit = axis->num_segments == 0 ? segments : segments + axis->num_segments;
AF_Segment seg;
FT_Fixed scale;
@@ -1153,7 +1153,7 @@
*/
{
AF_Edge edges = axis->edges;
- AF_Edge edge_limit = edges + axis->num_edges;
+ AF_Edge edge_limit = axis->num_edges == 0 ? edges : edges + axis->num_edges;
AF_Edge edge;
@@ -1291,7 +1291,7 @@
{
AF_AxisHints axis = &hints->axis[dim];
AF_Edge edge = axis->edges;
- AF_Edge edge_limit = edge + axis->num_edges;
+ AF_Edge edge_limit = axis->num_edges == 0 ? edge : edge + axis->num_edges;
AF_CJKAxis cjk = &metrics->axis[dim];
FT_Fixed scale = cjk->scale;
FT_Pos best_dist0; /* initial threshold */
@@ -1798,7 +1798,7 @@
{
AF_AxisHints axis = &hints->axis[dim];
AF_Edge edges = axis->edges;
- AF_Edge edge_limit = edges + axis->num_edges;
+ AF_Edge edge_limit = axis->num_edges == 0 ? edges : edges + axis->num_edges;
FT_PtrDist n_edges;
AF_Edge edge;
AF_Edge anchor = NULL;
@@ -2177,7 +2177,7 @@
{
AF_AxisHints axis = & hints->axis[dim];
AF_Edge edges = axis->edges;
- AF_Edge edge_limit = edges + axis->num_edges;
+ AF_Edge edge_limit = axis->num_edges == 0 ? edges : edges + axis->num_edges;
AF_Edge edge;
FT_Bool snapping;
--- src/autofit/afhints.c
+++ src/autofit/afhints.c
@@ -1316,7 +1316,7 @@
{
AF_AxisHints axis = & hints->axis[dim];
AF_Segment segments = axis->segments;
- AF_Segment segment_limit = segments + axis->num_segments;
+ AF_Segment segment_limit = axis->num_segments == 0 ? segments : segments + axis->num_segments;
AF_Segment seg;
@@ -1393,7 +1393,7 @@
AF_Point point_limit = points + hints->num_points;
AF_AxisHints axis = &hints->axis[dim];
AF_Edge edges = axis->edges;
- AF_Edge edge_limit = edges + axis->num_edges;
+ AF_Edge edge_limit = axis->num_edges == 0 ? edges : edges + axis->num_edges;
FT_UInt touch_flag;
--- src/autofit/aflatin.c
+++ src/autofit/aflatin.c
@@ -1989,7 +1989,7 @@
{
AF_AxisHints axis = &hints->axis[dim];
AF_Segment segments = axis->segments;
- AF_Segment segment_limit = segments + axis->num_segments;
+ AF_Segment segment_limit = axis->num_segments == 0 ? segments : segments + axis->num_segments;
FT_Pos len_threshold, len_score, dist_score, max_width;
AF_Segment seg1, seg2;
@@ -2134,7 +2134,7 @@
FT_Bool top_to_bottom_hinting = 0;
AF_Segment segments = axis->segments;
- AF_Segment segment_limit = segments + axis->num_segments;
+ AF_Segment segment_limit = axis->num_segments == 0 ? segments : segments + axis->num_segments;
AF_Segment seg;
#if 0
@@ -2500,7 +2500,7 @@
{
AF_AxisHints axis = &hints->axis[AF_DIMENSION_VERT];
AF_Edge edge = axis->edges;
- AF_Edge edge_limit = edge + axis->num_edges;
+ AF_Edge edge_limit = axis->num_edges == 0 ? edge : edge + axis->num_edges;
AF_LatinAxis latin = &metrics->axis[AF_DIMENSION_VERT];
FT_Fixed scale = latin->scale;
@@ -2993,7 +2993,7 @@
{
AF_AxisHints axis = &hints->axis[dim];
AF_Edge edges = axis->edges;
- AF_Edge edge_limit = edges + axis->num_edges;
+ AF_Edge edge_limit = axis->num_edges == 0 ? edges : edges + axis->num_edges;
FT_PtrDist n_edges;
AF_Edge edge;
AF_Edge anchor = NULL;
--- src/truetype/ttgxvar.c
+++ src/truetype/ttgxvar.c
@@ -964,7 +964,7 @@
/* in the OpenType specification. */
varData = &itemStore->varData[outerIndex];
- deltaSet = &varData->deltaSet[varData->regionIdxCount * innerIndex];
+ deltaSet = varData->regionIdxCount * innerIndex == 0 ? varData->deltaSet : &varData->deltaSet[varData->regionIdxCount * innerIndex];
/* outer loop steps through master designs to be blended */
for ( master = 0; master < varData->regionIdxCount; master++ )