]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
Fix segfaults in test suite when test font is missing 214/head
authorZdenek Dohnal <zdohnal@redhat.com>
Mon, 2 Mar 2020 13:56:55 +0000 (14:56 +0100)
committerZdenek Dohnal <zdohnal@redhat.com>
Mon, 2 Mar 2020 13:56:55 +0000 (14:56 +0100)
configure.ac
filter/test_pdf2.c
fontembed/test_analyze.c
fontembed/test_pdf.c
fontembed/test_ps.c

index d5fe836cc42af3d2b67be816bc36cbdb3c826307..7ffb6693c4d20abdacd64decd109bd3f1b5c80e5 100644 (file)
@@ -788,6 +788,9 @@ AC_ARG_WITH([test-font-path],
        [with_test_font_path="$withval"],
        [with_test_font_path="/usr/share/fonts/dejavu/DejaVuSans.ttf"]
 )
+AC_CHECK_FILE("$with_test_font_path", [], [
+       AC_MSG_ERROR([Requested font file is missing. Please install a package providing it.])
+])
 AC_DEFINE_UNQUOTED([TESTFONT], ["$with_test_font_path"], [Path to font used in tests])
 
 # ================
index a0c1d8b0d81a4f66a4c800595033b46229930b11..3d58a59d004f00e567f561da355d8d7a0fa7efff 100644 (file)
@@ -41,12 +41,18 @@ int main()
 
   // font, pt.1 
   const char *fn=TESTFONT;
+  OTF_FILE *otf=NULL;
 /*
   if (argc==2) {
     fn=argv[1];
   }
 */
-  OTF_FILE *otf=otf_load(fn);
+  otf=otf_load(fn);
+  if (!otf)
+  {
+    printf("Font %s was not loaded, exiting.\n", TESTFONT);
+    return 1;
+  }
   assert(otf);
   FONTFILE *ff=fontfile_open_sfnt(otf);
   EMB_PARAMS *emb=emb_new(ff,
index 3f42573d9dbe13f45c79968ecb3700c8f604dcbd..967a75169a9f227649c8051b3e976c8817483abd 100644 (file)
@@ -183,10 +183,17 @@ void show_hmtx(OTF_FILE *otf) // {{{
 int main(int argc,char **argv)
 {
   const char *fn=TESTFONT;
+  OTF_FILE *otf=NULL;
   if (argc==2) {
     fn=argv[1];
   }
-  OTF_FILE *otf=otf_load(fn);
+  otf=otf_load(fn);
+  if (!otf)
+  {
+    printf("Font %s was not loaded, exiting.\n", TESTFONT);
+    return 1;
+  }
+
   assert(otf);
   if (otf->numTTC) {
     printf("TTC has %d fonts, using %d\n",otf->numTTC,otf->useTTC);
index 565fd59f86350d0d6f4f33239da5d91ed837887e..881a4dca47d1209f96e01bb573477ea915f6550b 100644 (file)
@@ -72,10 +72,16 @@ static inline void write_string(FILE *f,EMB_PARAMS *emb,const char *str) // {{{
 int main(int argc,char **argv)
 {
   const char *fn=TESTFONT;
+  OTF_FILE *otf=NULL;
   if (argc==2) {
     fn=argv[1];
   }
-  OTF_FILE *otf=otf_load(fn);
+  otf=otf_load(fn);
+  if (!otf)
+  {
+    printf("Font %s was not loaded, exiting.\n", TESTFONT);
+    return 1;
+  }
   assert(otf);
   FONTFILE *ff=fontfile_open_sfnt(otf);
   EMB_PARAMS *emb=emb_new(ff,
index 1f8c2bb7917ccebf6ffceea2559e55a42d86a4a2..688d9392fca2aca947d3f3a283f516dee8695a8c 100644 (file)
@@ -45,10 +45,16 @@ static inline void write_string(FILE *f,EMB_PARAMS *emb,const char *str) // {{{
 int main(int argc,char **argv)
 {
   const char *fn=TESTFONT;
+  OTF_FILE *otf=NULL;
   if (argc==2) {
     fn=argv[1];
   }
-  OTF_FILE *otf=otf_load(fn);
+  otf=otf_load(fn);
+  if (!otf)
+  {
+    printf("Font %s was not loaded, exiting.\n", TESTFONT);
+    return 1;
+  }
   assert(otf);
   FONTFILE *ff=fontfile_open_sfnt(otf);
   EMB_PARAMS *emb=emb_new(ff,