Skip to content

Commit

Permalink
Fix a crash bug with bogus text (Issue #426)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed May 7, 2021
1 parent a0014be commit ee77825
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Fixed a crash bug with malformed URIs (Issue #418)
- Fixed a crash bug with malformed GIF files (Issue #423)
- Fixed a crash bug with empty titles (Issue #425)
- Fixed a crash bug with bogus text (Issue #426)
- Fixed some issues reported by Coverity.
- Removed the bundled libjpeg, libpng, and zlib.

Expand Down
4 changes: 2 additions & 2 deletions htmldoc/html.cxx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* HTML exporting functions for HTMLDOC, a HTML document processing program.
*
* Copyright 2011-2019 by Michael R Sweet.
* Copyright 2011-2021 by Michael R Sweet.
* Copyright 1997-2010 by Easy Software Products. All rights reserved.
*
* This program is free software. Distribution and use rights are outlined in
Expand Down Expand Up @@ -585,7 +585,7 @@ write_node(FILE *out, /* I - Output file */
for (ptr = t->data; *ptr; ptr ++)
fputs((char *)iso8859(*ptr), out);

if (t->data[strlen((char *)t->data) - 1] == '\n')
if (t->data[0] && t->data[strlen((char *)t->data) - 1] == '\n')
col = 0;
else
col += strlen((char *)t->data);
Expand Down
2 changes: 1 addition & 1 deletion htmldoc/htmllib.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ write_file(tree_t *t, /* I - Tree entry */
for (ptr = t->data; *ptr != '\0'; ptr ++)
fputs((char *)iso8859(*ptr), fp);

if (t->data[strlen((char *)t->data) - 1] == '\n')
if (t->data[0] && t->data[strlen((char *)t->data) - 1] == '\n')
col = 0;
else
col += strlen((char *)t->data);
Expand Down
2 changes: 1 addition & 1 deletion htmldoc/htmlsep.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ write_node(FILE *out, /* I - Output file */
for (ptr = t->data; *ptr; ptr ++)
fputs((char *)iso8859(*ptr), out);

if (t->data[strlen((char *)t->data) - 1] == '\n')
if (t->data[0] && t->data[strlen((char *)t->data) - 1] == '\n')
col = 0;
else
col += strlen((char *)t->data);
Expand Down

0 comments on commit ee77825

Please sign in to comment.