Skip to content

Commit

Permalink
Fix a crash bug with a bad title image (Issue #510)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Sep 13, 2023
1 parent 8eb9d42 commit 07c63af
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Now link to CUPS library instead of embedding its HTTP code.
- Fixed multiple conversions of UTF-8 HTML files from the GUI (Issue #496)
- Fixed some minor CodeQL warnings.
- Fixed a crash bug with bad title images (Issue #510)


# Changes in HTMLDOC v1.9.16
Expand Down
23 changes: 13 additions & 10 deletions htmldoc/html.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -495,16 +495,19 @@ write_title(FILE *out, /* I - Output file */
{
image_t *img = image_load(TitleImage, !OutputColor);

if (OutputFiles)
fprintf(out, "<IMG SRC=\"%s\" BORDER=\"0\" WIDTH=\"%d\" HEIGHT=\"%d\" "
"ALT=\"%s\"><BR>\n",
file_basename((char *)TitleImage), img->width, img->height,
title ? (char *)title : "");
else
fprintf(out, "<IMG SRC=\"%s\" BORDER=\"0\" WIDTH=\"%d\" HEIGHT=\"%d\" "
"ALT=\"%s\"><BR>\n",
TitleImage, img->width, img->height,
title ? (char *)title : "");
if (img)
{
if (OutputFiles)
fprintf(out, "<IMG SRC=\"%s\" BORDER=\"0\" WIDTH=\"%d\" HEIGHT=\"%d\" "
"ALT=\"%s\"><BR>\n",
file_basename((char *)TitleImage), img->width, img->height,
title ? (char *)title : "");
else
fprintf(out, "<IMG SRC=\"%s\" BORDER=\"0\" WIDTH=\"%d\" HEIGHT=\"%d\" "
"ALT=\"%s\"><BR>\n",
TitleImage, img->width, img->height,
title ? (char *)title : "");
}
}

if (title != NULL)
Expand Down
9 changes: 5 additions & 4 deletions htmldoc/htmlsep.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,11 @@ write_title(FILE *out, /* I - Output file */
{
image_t *img = image_load(TitleImage, !OutputColor);

fprintf(out, "<IMG SRC=\"%s\" WIDTH=\"%d\" HEIGHT=\"%d\" "
"ALT=\"%s\"><BR>\n",
file_basename((char *)TitleImage), img->width, img->height,
title ? (char *)title : "");
if (img)
fprintf(out, "<IMG SRC=\"%s\" WIDTH=\"%d\" HEIGHT=\"%d\" "
"ALT=\"%s\"><BR>\n",
file_basename((char *)TitleImage), img->width, img->height,
title ? (char *)title : "");
}

if (title != NULL)
Expand Down

0 comments on commit 07c63af

Please sign in to comment.