title: freetype 2 library crashes when trying to access characters map
body: <p>I'm trying to use <a href="https://github.com/cdave1/freetype2-android/issues/1" rel="nofollow">this</a> awesome version of freetype 2 with my multiplatform library. I didn't test it on Android yet, but I've tried to compile and test it under win32. It compiles just fine without errors, but it always crashes when library tries to read the "data" (which is always bad pointer) member of TT_CMap. The function wher it happens depends only of font file, i.e. one font - one place. I'vew tried different ttd fonts from Windows, MacOS X and from Android, but it affects only on position, where segmentation fault will occure. 
  For example, if I try to retreive index of any chracter of standard window arial.ttf font, it will always crash here:</p>
  
  <pre><code>static FT_UInt tt_cmap4_char_map_binary( TT_CMap     cmap, FT_UInt32*  pcharcode, FT_Bool     next )
  {
      [...]
      p = cmap-&gt;data + 6;
      num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 2 );
      [...]
  </code></pre>
  
  <p>because of cmap->data is invalid pointer.</p>
  
  <p>My test code looks like this:</p>
  
  <pre><code>int error = 0;
  
  // Initialize freetype library first
  error = FT_Init_FreeType( &amp;ft_lib );
  if ( error ) {
      ODF(("Unable to init freetype library! Error code is %d.\n", error));
      return false;
  }
  
  // Load font file into the memory buffer
  iMemBuff faceFileBuff;
  if (igelLoadResource(iString("Data/arial.ttf"), faceFileBuff) != ROR_Success) {
      ODF(("ERROR: Unable to open font file!\n"));
      return false;
  }
  
  // Init font
  error = FT_New_Memory_Face( ft_lib, (FT_Byte*)faceFileBuff.GetPtr(), faceFileBuff.GetSize(), 0, &amp;ft_face );
  if ( error == FT_Err_Unknown_File_Format ) {
      ODF(("ERROR: the font file could be opened and read, but it appears that its font format is unsupported.\n"));
      return false;
  } else if ( error ) {
      ODF(("ERROR: %d error code means that the font file could not be opened or read, or simply that it is broken...\n", error));
      return false;
  }
  
  // Setup font metrics
  error = FT_Set_Pixel_Sizes( ft_face, 0, 16 );
  // error = FT_Set_Char_Size(ft_face, 0, 16*64, 300, 300 );
  if ( error  ) {
      ODF(("ERROR: Unable to set char/pixel size! Error code %d.\n", error));
      return false;
  }
  
  
  
  sint32 ox = 0, oy = 0;
  int error = 0;
  FT_GlyphSlot  slot = ft_face-&gt;glyph;  // a small shortcut
  for (uint32 cc=0; cc&lt;text.StringSize(); ++cc) {
  
      // Find the character 'a' index
      int glyph_index = FT_Get_Char_Index( ft_face, text.CStr()[cc] );
  
      // Load glyph
      error = FT_Load_Glyph( ft_face, glyph_index, FT_LOAD_DEFAULT );
      if ( error  ) {
          ODF(("ERROR: Unable to load face from the font! Error code %d.\n", error));
          continue;
      }
  
      // Render the glyph
      error = FT_Render_Glyph( ft_face-&gt;glyph, FT_RENDER_MODE_NORMAL );
      if ( error  ) {
          ODF(("ERROR: Unable to render glyph! Error code %d.\n", error));
          continue;
      }
  
      // Draw the glyph to our target surface
      ComposeGlyph(image, &amp;slot-&gt;bitmap, ox + slot-&gt;bitmap_left, oy + slot-&gt;bitmap_top);
      ox += slot-&gt;advance.x &gt;&gt; 6;
  }
  </code></pre>
  
  <p>And it crashes when i call FT_Get_Char_Index with any character...</p>
  
  <p>Any Idea?</p>