More sanitize cleanup

This commit is contained in:
Behdad Esfahbod 2010-04-22 14:11:33 -04:00
parent 278a91f0cd
commit df3f505dcf
2 changed files with 4 additions and 24 deletions

View File

@ -110,16 +110,7 @@ typedef struct OffsetTable
public:
inline bool sanitize (SANITIZE_ARG_DEF, void *base) {
TRACE_SANITIZE ();
if (!(SANITIZE_SELF () && SANITIZE_ARRAY (tableDir, TableDirectory::get_size (), numTables))) return false;
return true;
/* No need to check tables individually since we don't sanitize the
* referenced table, just the table directory. Code retaind to make
* sure TableDirectory has a baseless sanitize(). */
unsigned int count = numTables;
for (unsigned int i = 0; i < count; i++)
if (!SANITIZE (tableDir[i]))
return false;
return true;
return SANITIZE_SELF () && SANITIZE_ARRAY (tableDir, TableDirectory::get_size (), numTables);
}
private:
@ -143,11 +134,7 @@ struct TTCHeader
STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (TTCHeader, 1, 2);
inline unsigned int get_face_count (void) const { return table.len; }
inline const OpenTypeFontFace& get_face (unsigned int i) const
{
return this+table[i];
}
inline const OpenTypeFontFace& get_face (unsigned int i) const { return this+table[i]; }
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
@ -199,13 +186,6 @@ struct OpenTypeFontFile
}
}
/* This is how you get a table */
inline const char* get_table_data (const OpenTypeTable& table) const
{
if (HB_UNLIKELY (table.offset == 0)) return NULL;
return CharP(this) + table.offset;
}
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
if (!SANITIZE_SELF ()) return false;

View File

@ -99,7 +99,7 @@ main (int argc, char **argv)
case GSUBGPOS::GPOSTag:
{
const GSUBGPOS &g = GSUBGPOS::get_for_data (ot.get_table_data (table));
const GSUBGPOS &g = GSUBGPOS::get_for_data ((const char *) &ot + table.offset);
int num_scripts = g.get_script_count ();
printf (" %d script(s) found in table\n", num_scripts);
@ -162,7 +162,7 @@ main (int argc, char **argv)
case GDEF::Tag:
{
const GDEF &gdef = GDEF::get_for_data (ot.get_table_data (table));
const GDEF &gdef = GDEF::get_for_data ((const char *) &ot + table.offset);
printf (" Has %sglyph classes\n",
gdef.has_glyph_classes () ? "" : "no ");