[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft-devel] suspicious code in FT_Set_Renderer
From: |
Tom Bishop, Wenlin Institute |
Subject: |
Re: [ft-devel] suspicious code in FT_Set_Renderer |
Date: |
Sun, 12 Dec 2010 22:33:18 -0800 |
On Dec 12, 2010, at 9:13 PM, Werner LEMBERG wrote:
>
>> While browsing freetype code I notice following code in
>> FT_Set_Renderer (src/base/ftobjs.c, v2.4.4 release):
>>
>> if ( num_params > 0 )
>> {
>> FT_Renderer_SetModeFunc set_mode = renderer->clazz->set_mode;
>>
>>
>> for ( ; num_params > 0; num_params-- )
>> {
>> error = set_mode( renderer, parameters->tag, parameters->data );
>> if ( error )
>> break;
>> }
>> }
>>
>> I believe that iteration over parameters expected here. Like:
>>
>> --- src/base/ftobjs.c (old)
>> +++ src/base/ftobjs.c (new)
>> @@ -3887,6 +3887,7 @@
>> error = set_mode( renderer, parameters->tag, parameters->data );
>> if ( error )
>> break;
>> + parameters++;
>> }
>> }
>
> Have you seen the `num_params--' in the `for' loop? It starts with
> num_params, then comes num_params-1, num_params-2, etc.
Still, why call set_mode() repeatedly if renderer and parameters are the same
each time? FT_Set_Renderer() seems to expect parameters[] to be an array with
num_params elements, but only the first element, parameters[0], is being
accessed. It looks suspiciously like the code is missing "parameters++" as the
original poster suggested. Maybe the code is supposed to be equivalent to the
following:
FT_UInt i;
for (i = 0; i < num_params; i++)
set_mode( renderer, parameters[i].tag, parameters[i].data );
(Unless there's a reason for doing the last parameter first?)
Tom
文林 Wenlin Institute, Inc. Software for Learning Chinese
E-mail: address@hidden Web: http://www.wenlin.com
Telephone: 1-877-4-WENLIN (1-877-493-6546)
☯