Skip to content

Commit

Permalink
Fix segfaults in test suite when test font is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
zdohnal committed Mar 2, 2020
1 parent cc157f3 commit 1d66106
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
3 changes: 3 additions & 0 deletions configure.ac
Expand Up @@ -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])

# ================
Expand Down
8 changes: 7 additions & 1 deletion filter/test_pdf2.c
Expand Up @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion fontembed/test_analyze.c
Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion fontembed/test_pdf.c
Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion fontembed/test_ps.c
Expand Up @@ -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,
Expand Down

0 comments on commit 1d66106

Please sign in to comment.