freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Devel] reallocate_t1_table bug


From: Martin Muskens
Subject: [Devel] reallocate_t1_table bug
Date: Tue, 28 Aug 2001 15:44:28 +0200

  Hi all,

I found a bug in the file psobjs.c in the routine PS_Table_Add. When the
routine reallocate_t1_table is called and the  table->block is reallocated,
the parameter object is not valid anymore. Inbetween #ifdef AURELON there
are patches.

greetings.

Martin Muskens

FT_LOCAL_DEF FT_Error
  PS_Table_Add( PS_Table*  table,
                FT_Int     index,
                void*      object,
                FT_Int     length )
  {
    if ( index < 0 || index > table->max_elems )
    {
      FT_ERROR(( "PS_Table_Add: invalid index\n" ));
      return PSaux_Err_Invalid_Argument;
    }

    /* grow the base block if needed */
    if ( table->cursor + length > table->capacity )
    {
      FT_Error   error;
      FT_Offset  new_size = table->capacity;
#ifdef AURELON
        FT_Long         inBlockOffset = -1;
        if( (FT_Byte*)object >= table->block && (FT_Byte*)object <
table->block + table->capacity )
                inBlockOffset = (FT_Byte*)object - table->block;
#endif

      while ( new_size < table->cursor + length )
        new_size += 1024;

      error = reallocate_t1_table( table, new_size );
      if ( error )
        return error;
#ifdef AURELON
        if( inBlockOffset >= 0 )
                object = table->block + inBlockOffset;
#endif
    }

    /* add the object to the base block and adjust offset */
    table->elements[index] = table->block + table->cursor;
    table->lengths [index] = length;
    MEM_Copy( table->block + table->cursor, object, length );

    table->cursor += length;
    return PSaux_Err_Ok;
  }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]