Fix invalid memory access in `bsdf` rasterizer.

Do not generate SDF from bitmap if the `FT_GLYPH_OWN_BITMAP`
flag is not set. In some cases the bitmap buffer is freed but
still points to a valid address, to handle those cases check
the flag before accessing the memory.

  * src/sdf/ftsdfrend.c (ft_bsdf_render): Handle the above case.
  Also, return an error message if the bitmap's rows/pitch is
  invalid, otherwise the slot->buffer might be assigned to some
  invalid memory location.

  * src/sdf/ftsdfrend.c (ft_sdf_render): Same as above. Plus, move
  the outline back to original state after rasterization and not
  if any error occurs.

Signed-off-by: Anuj Verma <>
8 jobs for bsdf-fix-invalid-memory-access in 58 seconds (queued for 4 seconds)