Commit 8cca0305c956fd92c2a65c73b0301abecb69c89c

Frank Heckenbach 2018-01-29T03:02:31

FTOutlineGlyphImpl, FTPolygonGlyphImpl: avoid uninizitalized vectoriser in case of error (see Debian bug #589601, 1.)

diff --git a/src/FTGlyph/FTOutlineGlyph.cpp b/src/FTGlyph/FTOutlineGlyph.cpp
index 3755072..a191a92 100644
--- a/src/FTGlyph/FTOutlineGlyph.cpp
+++ b/src/FTGlyph/FTOutlineGlyph.cpp
@@ -64,6 +64,7 @@ const FTPoint& FTOutlineGlyph::Render(const FTPoint& pen, int renderMode)
 FTOutlineGlyphImpl::FTOutlineGlyphImpl(FT_GlyphSlot glyph, float _outset,
                                        bool useDisplayList)
 :   FTGlyphImpl(glyph),
+    vectoriser(0),
     glList(0)
 {
     if(ft_glyph_format_outline != glyph->format)
diff --git a/src/FTGlyph/FTPolygonGlyph.cpp b/src/FTGlyph/FTPolygonGlyph.cpp
index 823b671..9562d33 100644
--- a/src/FTGlyph/FTPolygonGlyph.cpp
+++ b/src/FTGlyph/FTPolygonGlyph.cpp
@@ -64,6 +64,7 @@ const FTPoint& FTPolygonGlyph::Render(const FTPoint& pen, int renderMode)
 FTPolygonGlyphImpl::FTPolygonGlyphImpl(FT_GlyphSlot glyph, float _outset,
                                        bool useDisplayList)
 :   FTGlyphImpl(glyph),
+    vectoriser(0),
     glList(0)
 {
     if(ft_glyph_format_outline != glyph->format)
diff --git a/test/FTOutlineFont-UnInVec.cpp b/test/FTOutlineFont-UnInVec.cpp
new file mode 100644
index 0000000..c92cbc9
--- /dev/null
+++ b/test/FTOutlineFont-UnInVec.cpp
@@ -0,0 +1,44 @@
+//$LIBS_PKG_CONFIG glu gl ftgl fontconfig
+//$LIBS -lglut
+
+#include <GL/glut.h>
+#include <FTGL/ftgl.h>
+
+FTFont *font;
+
+void display ()
+{
+  glClear (GL_COLOR_BUFFER_BIT);
+  glMatrixMode (GL_PROJECTION);
+  glLoadIdentity ();
+  gluPerspective (90, 1, 1, 1000);
+  glMatrixMode (GL_MODELVIEW);
+  glLoadIdentity ();
+  gluLookAt (0, 0, 200, 0, 0, 0, 0, 1, 0);
+  glPushMatrix ();
+  glColor3f (1, 1, 1);
+  glEnable (GL_BLEND);
+  glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+  glTranslatef (-100, 100, 0);
+  font->Render ("Test", -1, FTPoint (), FTPoint (), FTGL::RENDER_FRONT | FTGL::RENDER_BACK);
+  glPopMatrix ();
+  glutSwapBuffers ();
+}
+
+int main (int argc, char **argv)
+{
+  glutInit (&argc, argv);
+  glutInitDisplayMode (GLUT_DEPTH | GLUT_RGB | GLUT_DOUBLE | GLUT_MULTISAMPLE);
+  glutInitWindowPosition (50, 50);
+  glutInitWindowSize (400, 400);
+  glutCreateWindow ("FTGL Test");
+  glutDisplayFunc (display);
+  const char *file = "/usr/share/fonts/X11/100dpi/timR12-ISO8859-1.pcf.gz";
+  font = new FTOutlineFont (file);
+  if (font->Error () || !font->FaceSize (17))
+    {
+      fprintf (stderr, "Failed to open font %s\n", file);
+      return 1;
+    }
+  glutMainLoop ();
+}
diff --git a/test/FTPolygonFont-UnInVec.cpp b/test/FTPolygonFont-UnInVec.cpp
new file mode 100644
index 0000000..5186e24
--- /dev/null
+++ b/test/FTPolygonFont-UnInVec.cpp
@@ -0,0 +1,44 @@
+//$LIBS_PKG_CONFIG glu gl ftgl fontconfig
+//$LIBS -lglut
+
+#include <GL/glut.h>
+#include <FTGL/ftgl.h>
+
+FTFont *font;
+
+void display ()
+{
+  glClear (GL_COLOR_BUFFER_BIT);
+  glMatrixMode (GL_PROJECTION);
+  glLoadIdentity ();
+  gluPerspective (90, 1, 1, 1000);
+  glMatrixMode (GL_MODELVIEW);
+  glLoadIdentity ();
+  gluLookAt (0, 0, 200, 0, 0, 0, 0, 1, 0);
+  glPushMatrix ();
+  glColor3f (1, 1, 1);
+  glEnable (GL_BLEND);
+  glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+  glTranslatef (-100, 100, 0);
+  font->Render ("Test", -1, FTPoint (), FTPoint (), FTGL::RENDER_FRONT | FTGL::RENDER_BACK);
+  glPopMatrix ();
+  glutSwapBuffers ();
+}
+
+int main (int argc, char **argv)
+{
+  glutInit (&argc, argv);
+  glutInitDisplayMode (GLUT_DEPTH | GLUT_RGB | GLUT_DOUBLE | GLUT_MULTISAMPLE);
+  glutInitWindowPosition (50, 50);
+  glutInitWindowSize (400, 400);
+  glutCreateWindow ("FTGL Test");
+  glutDisplayFunc (display);
+  const char *file = "/usr/share/fonts/X11/100dpi/timR12-ISO8859-1.pcf.gz";
+  font = new FTPolygonFont (file);
+  if (font->Error () || !font->FaceSize (17))
+    {
+      fprintf (stderr, "Failed to open font %s\n", file);
+      return 1;
+    }
+  glutMainLoop ();
+}