[HarfBuzz] harfbuzz: Branch 'master' - 4 commits
Simon Hausmann
hausmann at kemper.freedesktop.org
Tue Jun 22 03:18:01 PDT 2010
src/harfbuzz-gdef.c | 2 +-
src/harfbuzz-gpos.c | 34 ++++++++++++++++++++--------------
src/harfbuzz-open-private.h | 2 +-
src/harfbuzz-open.c | 15 +++++++--------
4 files changed, 29 insertions(+), 24 deletions(-)
New commits:
commit f0dcb906fe56b5dc06aa305b6cfc821d5dd25a28
Author: Simon Hausmann <simon.hausmann at nokia.com>
Date: Tue Jun 22 12:14:35 2010 +0200
Fix crash with certain fonts
Regressed with a1714c84f245beb182a2221a1832b041788af200 and
ab9a897b688e991a8405cf938dea9d6a2f1ac072, which removed the handling for value
records that specify an device advance tables but do not actually have an
offset for it.
Previously HB_OPEN_Get_Device handled this through the HB_Device being
allocated as structure and zero initialized. Now this case is represented
by a null pointer HB_Device, which we must handle.
Reviewed-by: Andreas Kling <andreas.kling at nokia.com>
diff --git a/src/harfbuzz-open.c b/src/harfbuzz-open.c
index 15cd2c1..f12f5b7 100644
--- a/src/harfbuzz-open.c
+++ b/src/harfbuzz-open.c
@@ -1403,12 +1403,11 @@ _HB_OPEN_Get_Device( HB_Device* d,
HB_UShort size,
HB_Short* value )
{
- HB_UShort byte, bits, mask, f, s;
+ HB_UShort byte, bits, mask, s;
- f = d->DeltaFormat;
-
- if ( d->DeltaValue && size >= d->StartSize && size <= d->EndSize )
+ if ( d && d->DeltaValue && size >= d->StartSize && size <= d->EndSize )
{
+ HB_UShort f = d->DeltaFormat;
s = size - d->StartSize;
byte = d->DeltaValue[s >> ( 4 - f )];
bits = byte >> ( 16 - ( ( s % ( 1 << ( 4 - f ) ) + 1 ) << f ) );
commit 16d8ab747c65024102c0e1415584ace91cc78613
Author: Andreas Kling <andreas.kling at nokia.com>
Date: Tue Jun 22 09:37:34 2010 +0200
Clean up HB_Anchor's DeviceTables on failure when loading format 3
Signed-off-by: Simon Hausmann <simon.hausmann at nokia.com>
diff --git a/src/harfbuzz-gpos.c b/src/harfbuzz-gpos.c
index d6f9207..a216005 100644
--- a/src/harfbuzz-gpos.c
+++ b/src/harfbuzz-gpos.c
@@ -637,7 +637,7 @@ static HB_Error Load_Anchor( HB_Anchor* an,
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_Device( &an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE],
stream ) ) != HB_Err_Ok )
- return error;
+ goto Fail2;
(void)FILE_Seek( cur_offset );
}
@@ -695,6 +695,7 @@ Fail:
if ( an->af.af3.DeviceTables )
_HB_OPEN_Free_Device( an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE] );
+Fail2:
FREE( an->af.af3.DeviceTables );
return error;
}
commit 009a7e76ad2a96b33a45ca48ee724bbf2de71efa
Author: Andreas Kling <andreas.kling at nokia.com>
Date: Tue Jun 22 09:09:32 2010 +0200
Make sure ValueRecord's DeviceTables are cleaned up on failure
Cleanup was a missing for the case where loading an X placement
device table failed.
Signed-off-by: Simon Hausmann <simon.hausmann at nokia.com>
diff --git a/src/harfbuzz-gpos.c b/src/harfbuzz-gpos.c
index 0236271..d6f9207 100644
--- a/src/harfbuzz-gpos.c
+++ b/src/harfbuzz-gpos.c
@@ -273,7 +273,7 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr,
if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE )
{
if ( ACCESS_Frame( 2L ) )
- return error;
+ goto Fail4;
new_offset = GET_UShort();
@@ -287,7 +287,7 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr,
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_Device( &vr->DeviceTables[VR_X_PLACEMENT_DEVICE],
stream ) ) != HB_Err_Ok )
- return error;
+ goto Fail4;
(void)FILE_Seek( cur_offset );
}
}
@@ -444,6 +444,7 @@ Fail3:
if ( vr->DeviceTables )
_HB_OPEN_Free_Device( vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] );
+Fail4:
FREE( vr->DeviceTables );
return error;
}
commit 04bf97ef1227e15b65ba18a7b74ace790df69903
Author: Andreas Kling <andreas.kling at nokia.com>
Date: Mon Jun 21 18:52:45 2010 +0200
Fix null HB_Device** dereference on exit in Harfbuzz GPOS code Fix incorrect usage of _HB_OPEN_Free_Device() in CaretValue cleanup
Signed-off-by: Simon Hausmann <simon.hausmann at nokia.com>
diff --git a/src/harfbuzz-gdef.c b/src/harfbuzz-gdef.c
index c0c6f2c..966b167 100644
--- a/src/harfbuzz-gdef.c
+++ b/src/harfbuzz-gdef.c
@@ -462,7 +462,7 @@ static HB_Error Load_CaretValue( HB_CaretValue* cv,
static void Free_CaretValue( HB_CaretValue* cv)
{
if ( cv->CaretValueFormat == 3 )
- _HB_OPEN_Free_Device( &cv->cvf.cvf3.Device );
+ _HB_OPEN_Free_Device( cv->cvf.cvf3.Device );
}
diff --git a/src/harfbuzz-gpos.c b/src/harfbuzz-gpos.c
index 31b9ae1..0236271 100644
--- a/src/harfbuzz-gpos.c
+++ b/src/harfbuzz-gpos.c
@@ -433,13 +433,16 @@ static HB_Error Load_ValueRecord( HB_ValueRecord* vr,
return HB_Err_Ok;
Fail1:
- _HB_OPEN_Free_Device( &vr->DeviceTables[VR_Y_ADVANCE_DEVICE] );
+ if ( vr->DeviceTables )
+ _HB_OPEN_Free_Device( vr->DeviceTables[VR_Y_ADVANCE_DEVICE] );
Fail2:
- _HB_OPEN_Free_Device( &vr->DeviceTables[VR_X_ADVANCE_DEVICE] );
+ if ( vr->DeviceTables )
+ _HB_OPEN_Free_Device( vr->DeviceTables[VR_X_ADVANCE_DEVICE] );
Fail3:
- _HB_OPEN_Free_Device( &vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] );
+ if ( vr->DeviceTables )
+ _HB_OPEN_Free_Device( vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] );
FREE( vr->DeviceTables );
return error;
@@ -450,13 +453,13 @@ static void Free_ValueRecord( HB_ValueRecord* vr,
HB_UShort format )
{
if ( format & HB_GPOS_FORMAT_HAVE_Y_ADVANCE_DEVICE )
- _HB_OPEN_Free_Device( &vr->DeviceTables[VR_Y_ADVANCE_DEVICE] );
+ _HB_OPEN_Free_Device( vr->DeviceTables[VR_Y_ADVANCE_DEVICE] );
if ( format & HB_GPOS_FORMAT_HAVE_X_ADVANCE_DEVICE )
- _HB_OPEN_Free_Device( &vr->DeviceTables[VR_X_ADVANCE_DEVICE] );
+ _HB_OPEN_Free_Device( vr->DeviceTables[VR_X_ADVANCE_DEVICE] );
if ( format & HB_GPOS_FORMAT_HAVE_Y_PLACEMENT_DEVICE )
- _HB_OPEN_Free_Device( &vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] );
+ _HB_OPEN_Free_Device( vr->DeviceTables[VR_Y_PLACEMENT_DEVICE] );
if ( format & HB_GPOS_FORMAT_HAVE_X_PLACEMENT_DEVICE )
- _HB_OPEN_Free_Device( &vr->DeviceTables[VR_X_PLACEMENT_DEVICE] );
+ _HB_OPEN_Free_Device( vr->DeviceTables[VR_X_PLACEMENT_DEVICE] );
FREE( vr->DeviceTables );
}
@@ -688,7 +691,8 @@ static HB_Error Load_Anchor( HB_Anchor* an,
return HB_Err_Ok;
Fail:
- _HB_OPEN_Free_Device( &an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE] );
+ if ( an->af.af3.DeviceTables )
+ _HB_OPEN_Free_Device( an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE] );
FREE( an->af.af3.DeviceTables );
return error;
@@ -697,10 +701,10 @@ Fail:
static void Free_Anchor( HB_Anchor* an)
{
- if ( an->PosFormat == 3 )
+ if ( an->PosFormat == 3 && an->af.af3.DeviceTables )
{
- _HB_OPEN_Free_Device( &an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE] );
- _HB_OPEN_Free_Device( &an->af.af3.DeviceTables[AF3_Y_DEVICE_TABLE] );
+ _HB_OPEN_Free_Device( an->af.af3.DeviceTables[AF3_X_DEVICE_TABLE] );
+ _HB_OPEN_Free_Device( an->af.af3.DeviceTables[AF3_Y_DEVICE_TABLE] );
FREE( an->af.af3.DeviceTables );
}
}
diff --git a/src/harfbuzz-open-private.h b/src/harfbuzz-open-private.h
index 65ca453..f1ca278 100644
--- a/src/harfbuzz-open-private.h
+++ b/src/harfbuzz-open-private.h
@@ -79,7 +79,7 @@ HB_INTERNAL void _HB_OPEN_Free_LookupList( HB_LookupList* ll,
HB_INTERNAL void _HB_OPEN_Free_Coverage( HB_Coverage* c );
HB_INTERNAL void _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition* cd );
-HB_INTERNAL void _HB_OPEN_Free_Device( HB_Device** d );
+HB_INTERNAL void _HB_OPEN_Free_Device( HB_Device* d );
diff --git a/src/harfbuzz-open.c b/src/harfbuzz-open.c
index adc6cec..15cd2c1 100644
--- a/src/harfbuzz-open.c
+++ b/src/harfbuzz-open.c
@@ -1353,12 +1353,12 @@ _HB_OPEN_Load_Device( HB_Device** device,
HB_INTERNAL void
-_HB_OPEN_Free_Device( HB_Device** d )
+_HB_OPEN_Free_Device( HB_Device* d )
{
- if ( *d )
+ if ( d )
{
- FREE( (*d)->DeltaValue );
- FREE( *d );
+ FREE( d->DeltaValue );
+ FREE( d );
}
}
More information about the HarfBuzz
mailing list