From 319c00d7d6cb46b8abd4e64d5afcca619088fed9 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Wed, 23 Apr 2003 19:48:24 +0000 Subject: [PATCH] Fixing bugs reported by Nelson Beebe. * src/base/ftstroker.c (FT_Stroker_ParseOutline): Remove unused variable `in_path'. * src/base/ftobjs (ft_glyphslot_set_bitmap): Change type of second argument to `FT_Byte*'. * include/freetype/internal/ftobjs.h: Updated. * src/bdf/bdflib.c (_bdf_readstream): Remove unused variable `res'. (_bdf_parse_glyphs): Remove unused variable `next'. Mark `call_data' as unused. * src/cache/ftlru.c (FT_LruList_Lookup): Remove unused variable `plast'. * src/pcf/pcfread.c (pcf_seek_to_table_type): Slight recoding to actually use `error'. (pcf_load_font): Remove unused variable `avgw'. * src/pfr/pfrobjs.c (pfr_face_get_kerning): Change return type to `void'. Mark `error' as unused. * src/pfr/pfrobjs.h: Updated. * src/pfr/pfrdrivr.c (pfr_get_kerning): Updated. * src/sfnt/ttload.c (sfnt_dir_check): Remove unused variable `format_tag'. * src/sfnt/ttcmap0.c (tt_cmap6_validate, tt_cmap10_validate): Remove unused variable `start'. (tt_cmap10_char_next): Remove unused variable `result' * src/sfnt/sfobjs.c (tt_face_get_name): Mark `error' as unused. * src/sfnt/sfdriver.c (get_sfnt_postscript_name): Mark `error' as unused. * src/type1/t1objs.c (T1_Face_Init): Remove unused variable `pshinter'. * src/type1/t1gload.c (T1_Load_Glyph): Use `glyph_data_loaded' only for FT_CONFIG_OPTION_INCREMENTAL. --- ChangeLog | 46 ++++++++++++++++++++++++++++++ include/freetype/internal/ftobjs.h | 2 +- src/base/ftobjs.c | 7 +++-- src/base/ftstroker.c | 5 ---- src/bdf/bdflib.c | 11 ++++--- src/cache/ftlru.c | 4 --- src/pcf/pcfread.c | 22 ++++++++------ src/pfr/pfrdrivr.c | 29 ++++++++----------- src/pfr/pfrobjs.c | 14 ++++----- src/pfr/pfrobjs.h | 12 ++++---- src/sfnt/sfdriver.c | 10 +++++-- src/sfnt/sfobjs.c | 6 ++-- src/sfnt/ttcmap0.c | 14 +++------ src/sfnt/ttload.c | 5 +--- src/type1/t1gload.c | 4 +++ src/type1/t1objs.c | 4 +-- 16 files changed, 115 insertions(+), 80 deletions(-) diff --git a/ChangeLog b/ChangeLog index dd78eb332..61de2ac25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,49 @@ +2003-04-23 Werner Lemberg + + Fixing bugs reported by Nelson Beebe. + + * src/base/ftstroker.c (FT_Stroker_ParseOutline): Remove unused + variable `in_path'. + + * src/base/ftobjs (ft_glyphslot_set_bitmap): Change type of + second argument to `FT_Byte*'. + * include/freetype/internal/ftobjs.h: Updated. + + * src/bdf/bdflib.c (_bdf_readstream): Remove unused variable `res'. + (_bdf_parse_glyphs): Remove unused variable `next'. + Mark `call_data' as unused. + + * src/cache/ftlru.c (FT_LruList_Lookup): Remove unused variable + `plast'. + + * src/pcf/pcfread.c (pcf_seek_to_table_type): Slight recoding to + actually use `error'. + (pcf_load_font): Remove unused variable `avgw'. + + * src/pfr/pfrobjs.c (pfr_face_get_kerning): Change return type + to `void'. + Mark `error' as unused. + * src/pfr/pfrobjs.h: Updated. + * src/pfr/pfrdrivr.c (pfr_get_kerning): Updated. + + * src/sfnt/ttload.c (sfnt_dir_check): Remove unused variable + `format_tag'. + + * src/sfnt/ttcmap0.c (tt_cmap6_validate, tt_cmap10_validate): Remove + unused variable `start'. + (tt_cmap10_char_next): Remove unused variable `result' + + * src/sfnt/sfobjs.c (tt_face_get_name): Mark `error' as unused. + + * src/sfnt/sfdriver.c (get_sfnt_postscript_name): Mark `error' as + unused. + + * src/type1/t1objs.c (T1_Face_Init): Remove unused variable + `pshinter'. + + * src/type1/t1gload.c (T1_Load_Glyph): Use `glyph_data_loaded' + only for FT_CONFIG_OPTION_INCREMENTAL. + 2003-04-23 Akito Hirai * src/sfnt/ttcmap0.c (tt_cmap4_validate): Provide a weak variant diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h index 483e6ecdc..e60cb2205 100644 --- a/include/freetype/internal/ftobjs.h +++ b/include/freetype/internal/ftobjs.h @@ -560,7 +560,7 @@ FT_BEGIN_HEADER */ FT_BASE( void ) ft_glyphslot_set_bitmap( FT_GlyphSlot slot, - FT_Pointer buffer ); + FT_Byte* buffer ); /*************************************************************************/ diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 08708d12a..dd873cdf6 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -220,7 +220,7 @@ FT_BASE_DEF( void ) ft_glyphslot_set_bitmap( FT_GlyphSlot slot, - FT_Pointer buffer ) + FT_Byte* buffer ) { ft_glyphslot_free_bitmap( slot ); @@ -429,11 +429,12 @@ /* documentation is in freetype.h */ FT_EXPORT_DEF( void ) - FT_Set_Hint_Flags( FT_Face face, - FT_ULong flags ) + FT_Set_Hint_Flags( FT_Face face, + FT_ULong flags ) { FT_Face_Internal internal; + if ( !face ) return; diff --git a/src/base/ftstroker.c b/src/base/ftstroker.c index 66fe19a43..9b19bc8b2 100644 --- a/src/base/ftstroker.c +++ b/src/base/ftstroker.c @@ -1489,7 +1489,6 @@ FT_Int n; /* index of contour in outline */ FT_UInt first; /* index of first point in contour */ FT_Int tag; /* current point's state */ - FT_Int in_path; if ( !outline || !stroker ) @@ -1497,8 +1496,6 @@ first = 0; - in_path = 0; - for ( n = 0; n < outline->n_contours; n++ ) { FT_Int last; /* index of last point in contour */ @@ -1548,8 +1545,6 @@ if ( error ) goto Exit; - in_path = 1; - while ( point < limit ) { point++; diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c index 7496e6061..06ce4ddbb 100644 --- a/src/bdf/bdflib.c +++ b/src/bdf/bdflib.c @@ -1,6 +1,6 @@ /* * Copyright 2000 Computing Research Labs, New Mexico State University - * Copyright 2001, 2002 Francesco Zappa Nardelli + * Copyright 2001, 2002, 2003 Francesco Zappa Nardelli * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -641,7 +641,7 @@ { _bdf_line_func_t cb; unsigned long lineno; - int n, res, done, refill, bytes, hold; + int n, done, refill, bytes, hold; char *ls, *le, *pp, *pe, *hp; char *buf = 0; FT_Memory memory = stream->memory; @@ -661,7 +661,7 @@ lineno = 1; buf[0] = 0; - res = done = 0; + done = 0; pp = ls = le = buf; bytes = 65536L; @@ -1443,7 +1443,6 @@ unsigned char* bp; unsigned long i, slen, nibbles; - _bdf_line_func_t* next; _bdf_parse_t* p; bdf_glyph_t* glyph; bdf_font_t* font; @@ -1451,11 +1450,11 @@ FT_Memory memory; FT_Error error = BDF_Err_Ok; + FT_UNUSED( call_data ); FT_UNUSED( lineno ); /* only used in debug mode */ - next = (_bdf_line_func_t *)call_data; - p = (_bdf_parse_t *) client_data; + p = (_bdf_parse_t *)client_data; font = p->font; memory = font->memory; diff --git a/src/cache/ftlru.c b/src/cache/ftlru.c index bd450befe..eb2065a17 100644 --- a/src/cache/ftlru.c +++ b/src/cache/ftlru.c @@ -130,7 +130,6 @@ FT_Error error = 0; FT_LruNode node, *pnode; FT_LruList_Class clazz; - FT_LruNode* plast; FT_LruNode result = NULL; FT_Memory memory; @@ -139,7 +138,6 @@ return FTC_Err_Invalid_Argument; pnode = &list->nodes; - plast = pnode; node = NULL; clazz = list->clazz; memory = list->memory; @@ -155,7 +153,6 @@ if ( clazz->node_compare( node, key, list->data ) ) break; - plast = pnode; pnode = &(*pnode)->next; } } @@ -170,7 +167,6 @@ if ( node->key == key ) break; - plast = pnode; pnode = &(*pnode)->next; } } diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c index e3bbf0606..8e89acec0 100644 --- a/src/pcf/pcfread.c +++ b/src/pcf/pcfread.c @@ -2,7 +2,7 @@ FreeType font driver for pcf fonts - Copyright 2000-2001, 2002 by + Copyright 2000, 2001, 2002, 2003 by Francesco Zappa Nardelli Permission is hereby granted, free of charge, to any person obtaining a copy @@ -250,18 +250,22 @@ THE SOFTWARE. FT_ULong *aformat, FT_ULong *asize ) { - FT_Error error = 0; + FT_Error error = PCF_Err_Invalid_File_Format; FT_Int i; for ( i = 0; i < ntables; i++ ) if ( tables[i].type == type ) { - if ( stream->pos > tables[i].offset ) - return PCF_Err_Invalid_Stream_Skip; + if ( stream->pos > tables[i].offset ) { + error = PCF_Err_Invalid_Stream_Skip; + goto Fail; + } - if ( FT_STREAM_SKIP( tables[i].offset - stream->pos ) ) - return PCF_Err_Invalid_Stream_Skip; + if ( FT_STREAM_SKIP( tables[i].offset - stream->pos ) ) { + error = PCF_Err_Invalid_Stream_Skip; + goto Fail; + } *asize = tables[i].size; /* unused - to be removed */ *aformat = tables[i].format; @@ -269,7 +273,8 @@ THE SOFTWARE. return PCF_Err_Ok; } - return PCF_Err_Invalid_File_Format; + Fail: + return error; } @@ -986,12 +991,11 @@ THE SOFTWARE. prop = pcf_find_property( face, "POINT_SIZE" ); if ( prop != NULL ) { - PCF_Property xres, yres, avgw; + PCF_Property xres, yres; xres = pcf_find_property( face, "RESOLUTION_X" ); yres = pcf_find_property( face, "RESOLUTION_Y" ); - avgw = pcf_find_property( face, "AVERAGE_WIDTH" ); if ( ( yres != NULL ) && ( xres != NULL ) ) { diff --git a/src/pfr/pfrdrivr.c b/src/pfr/pfrdrivr.c index d75b3a33c..9c11b1f00 100644 --- a/src/pfr/pfrdrivr.c +++ b/src/pfr/pfrdrivr.c @@ -30,29 +30,24 @@ FT_UInt right, FT_Vector *avector ) { - FT_Error error; + PFR_PhyFont phys = &face->phy_font; - error = pfr_face_get_kerning( face, left, right, avector ); - if ( !error ) + pfr_face_get_kerning( face, left, right, avector ); + + /* convert from metrics to outline units when necessary */ + if ( phys->outline_resolution != phys->metrics_resolution ) { - PFR_PhyFont phys = &face->phy_font; + if ( avector->x != 0 ) + avector->x = FT_MulDiv( avector->x, phys->outline_resolution, + phys->metrics_resolution ); - - /* convert from metrics to outline units when necessary */ - if ( phys->outline_resolution != phys->metrics_resolution ) - { - if ( avector->x != 0 ) - avector->x = FT_MulDiv( avector->x, phys->outline_resolution, - phys->metrics_resolution ); - - if ( avector->y != 0 ) - avector->y = FT_MulDiv( avector->x, phys->outline_resolution, - phys->metrics_resolution ); - } + if ( avector->y != 0 ) + avector->y = FT_MulDiv( avector->x, phys->outline_resolution, + phys->metrics_resolution ); } - return error; + return FT_Err_Ok; } diff --git a/src/pfr/pfrobjs.c b/src/pfr/pfrobjs.c index 84f99ad6a..46732229b 100644 --- a/src/pfr/pfrobjs.c +++ b/src/pfr/pfrobjs.c @@ -397,17 +397,19 @@ /*************************************************************************/ /*************************************************************************/ - FT_LOCAL_DEF( FT_Error ) + FT_LOCAL_DEF( void ) pfr_face_get_kerning( PFR_Face face, FT_UInt glyph1, FT_UInt glyph2, FT_Vector* kerning ) { - FT_Error error; + FT_Error error = FT_Err_Ok; PFR_PhyFont phy_font = &face->phy_font; PFR_KernItem item = phy_font->kern_items; FT_UInt32 idx = PFR_KERN_INDEX( glyph1, glyph2 ); + FT_UNUSED( error ); /* just needed as syntactical sugar */ + kerning->x = 0; kerning->y = 0; @@ -422,7 +424,7 @@ } /* not found */ - goto Exit; + return; Found_Item: { @@ -434,7 +436,7 @@ if ( FT_STREAM_SEEK( item->offset ) || FT_FRAME_ENTER( item->pair_count * item->pair_size ) ) - goto Exit; + return; min = 0; max = item->pair_count; @@ -475,9 +477,7 @@ FT_FRAME_EXIT(); } - - Exit: - return 0; } + /* END */ diff --git a/src/pfr/pfrobjs.h b/src/pfr/pfrobjs.h index b29b64c6c..efd7b7c6d 100644 --- a/src/pfr/pfrobjs.h +++ b/src/pfr/pfrobjs.h @@ -4,7 +4,7 @@ /* */ /* FreeType PFR object methods (specification). */ /* */ -/* Copyright 2002 by */ +/* Copyright 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -67,11 +67,11 @@ FT_BEGIN_HEADER pfr_face_done( PFR_Face face ); - FT_LOCAL( FT_Error ) - pfr_face_get_kerning( PFR_Face face, - FT_UInt glyph1, - FT_UInt glyph2, - FT_Vector* kerning ); + FT_LOCAL( void ) + pfr_face_get_kerning( PFR_Face face, + FT_UInt glyph1, + FT_UInt glyph2, + FT_Vector* kerning ); FT_LOCAL( FT_Error ) diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c index c4dd1b478..0e5f7e632 100644 --- a/src/sfnt/sfdriver.c +++ b/src/sfnt/sfdriver.c @@ -4,7 +4,7 @@ /* */ /* High-level SFNT driver interface (body). */ /* */ -/* Copyright 1996-2001, 2002 by */ +/* Copyright 1996-2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -149,7 +149,9 @@ FT_Memory memory = face->root.memory; TT_NameEntryRec* name = face->name_table.names + found_win; FT_UInt len = name->stringLength / 2; - FT_Error error; + FT_Error error = FT_Err_Ok; + + FT_UNUSED( error ); if ( !FT_ALLOC( result, name->stringLength + 1 ) ) @@ -189,7 +191,9 @@ FT_Memory memory = face->root.memory; TT_NameEntryRec* name = face->name_table.names + found_apple; FT_UInt len = name->stringLength; - FT_Error error; + FT_Error error = FT_Err_Ok; + + FT_UNUSED( error ); if ( !FT_ALLOC( result, len + 1 ) ) diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index adaca2440..08c24bea7 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -4,7 +4,7 @@ /* */ /* SFNT object management (base). */ /* */ -/* Copyright 1996-2001, 2002 by */ +/* Copyright 1996-2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -258,9 +258,11 @@ { if ( rec->string == NULL ) { - FT_Error error; + FT_Error error = FT_Err_Ok; FT_Stream stream = face->name_table.stream; + FT_UNUSED( error ); + if ( FT_NEW_ARRAY ( rec->string, rec->stringLength ) || FT_STREAM_SEEK( rec->stringOffset ) || diff --git a/src/sfnt/ttcmap0.c b/src/sfnt/ttcmap0.c index 613a9f8ec..d87aed859 100644 --- a/src/sfnt/ttcmap0.c +++ b/src/sfnt/ttcmap0.c @@ -1018,7 +1018,7 @@ FT_Validator valid ) { FT_Byte* p; - FT_UInt length, start, count; + FT_UInt length, count; if ( table + 10 > valid->limit ) @@ -1027,8 +1027,7 @@ p = table + 2; length = TT_NEXT_USHORT( p ); - p = table + 6; /* skip language */ - start = TT_NEXT_USHORT( p ); + p = table + 8; /* skip language and start index */ count = TT_NEXT_USHORT( p ); if ( table + length > valid->limit || length < 10 + count * 2 ) @@ -1399,15 +1398,14 @@ FT_Validator valid ) { FT_Byte* p = table + 4; - FT_ULong length, start, count; + FT_ULong length, count; if ( table + 20 > valid->limit ) FT_INVALID_TOO_SHORT; length = TT_NEXT_ULONG( p ); - p = table + 12; - start = TT_NEXT_ULONG( p ); + p = table + 16; count = TT_NEXT_ULONG( p ); if ( table + length > valid->limit || length < 20 + count * 2 ) @@ -1455,7 +1453,6 @@ FT_UInt32 *pchar_code ) { FT_Byte* table = cmap->data; - FT_UInt32 result = 0; FT_UInt32 char_code = *pchar_code + 1; FT_UInt gindex = 0; FT_Byte* p = table + 12; @@ -1474,10 +1471,7 @@ { gindex = TT_NEXT_USHORT( p ); if ( gindex != 0 ) - { - result = char_code; break; - } char_code++; } diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c index 78e402dc6..f056bccbe 100644 --- a/src/sfnt/ttload.c +++ b/src/sfnt/ttload.c @@ -179,11 +179,8 @@ /* if 'num_tables' is 0, read the table count from the file */ if ( num_tables == 0 ) { - FT_ULong format_tag; - - if ( FT_STREAM_SEEK( offset ) || - FT_READ_ULONG ( format_tag ) || + FT_STREAM_SKIP( 4 ) || FT_READ_USHORT( num_tables ) || FT_STREAM_SKIP( 6 ) ) goto Bad_Format; diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c index 6a28ac60e..1a98daf3c 100644 --- a/src/type1/t1gload.c +++ b/src/type1/t1gload.c @@ -226,7 +226,9 @@ FT_Matrix font_matrix; FT_Vector font_offset; FT_Data glyph_data; +#ifdef FT_CONFIG_OPTION_INCREMENTAL FT_Bool glyph_data_loaded = 0; +#endif if ( load_flags & FT_LOAD_NO_RECURSE ) @@ -267,7 +269,9 @@ &glyph_data ); if ( error ) goto Exit; +#ifdef FT_CONFIG_OPTION_INCREMENTAL glyph_data_loaded = 1; +#endif font_matrix = decoder.font_matrix; font_offset = decoder.font_offset; diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c index 59e7cb686..5933adf9f 100644 --- a/src/type1/t1objs.c +++ b/src/type1/t1objs.c @@ -4,7 +4,7 @@ /* */ /* Type 1 objects manager (body). */ /* */ -/* Copyright 1996-2001, 2002 by */ +/* Copyright 1996-2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -278,7 +278,6 @@ FT_Error error; PSNames_Service psnames; PSAux_Service psaux; - PSHinter_Service pshinter; FT_UNUSED( num_params ); FT_UNUSED( params ); @@ -298,7 +297,6 @@ face->pshinter = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ), "pshinter" ); - pshinter = (PSHinter_Service)face->pshinter; /* open the tokenizer, this will also check the font format */ error = T1_Open_Face( face );