[base] Fix `NULL + offset' sanitizer warnings (#57194).

* src/base/ftgloadr.c (FT_GlyphLoader_Adjust_Points,
FT_GlyphLoader_Adjust_Subglyphs): Use `FT_OFFSET'.
(FT_GlyphLoader_CreateExtra): Add short cut if some values are zero.
This commit is contained in:
John Stracke 2019-11-23 10:42:04 +01:00 committed by Werner Lemberg
parent 26d0f579c0
commit 2d1d60aac6
2 changed files with 17 additions and 4 deletions

View File

@ -1,3 +1,12 @@
2019-11-23 John Stracke <jstracke@Google.com>
Werner Lemberg <wl@gnu.org>
[base] Fix `NULL + offset' sanitizer warnings (#57194).
* src/base/ftgloadr.c (FT_GlyphLoader_Adjust_Points,
FT_GlyphLoader_Adjust_Subglyphs): Use `FT_OFFSET'.
(FT_GlyphLoader_CreateExtra): Add short cut if some values are zero.
2019-11-23 Werner Lemberg <wl@gnu.org>
* include/freetype/internal/ftmemory.h (FT_OFFSET): New macro.

View File

@ -146,9 +146,9 @@
FT_Outline* current = &loader->current.outline;
current->points = base->points + base->n_points;
current->tags = base->tags + base->n_points;
current->contours = base->contours + base->n_contours;
current->points = FT_OFFSET( base->points, base->n_points );
current->tags = FT_OFFSET( base->tags, base->n_points );
current->contours = FT_OFFSET( base->contours, base->n_contours );
/* handle extra points table - if any */
if ( loader->use_extra )
@ -169,6 +169,10 @@
FT_Memory memory = loader->memory;
if ( loader->max_points == 0 ||
loader->base.extra_points != NULL )
return FT_Err_Ok;
if ( !FT_NEW_ARRAY( loader->base.extra_points, 2 * loader->max_points ) )
{
loader->use_extra = 1;
@ -189,7 +193,7 @@
FT_GlyphLoad current = &loader->current;
current->subglyphs = base->subglyphs + base->num_subglyphs;
current->subglyphs = FT_OFFSET( base->subglyphs, base->num_subglyphs );
}