aboutsummaryrefslogtreecommitdiffstats
path: root/table.c
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@debian.org>2016-11-15 11:11:52 +0000
committerTatsuya Kinoshita <tats@debian.org>2016-11-15 11:11:52 +0000
commit2a4a2fb9f116b50e7c80d573db06c0fdc6c69272 (patch)
tree83f553c51099d3cd823efb0a9806ca66fb579c10 /table.c
parentRevert "Prevent infinite recursion with nested table and textarea" (diff)
downloadw3m-2a4a2fb9f116b50e7c80d573db06c0fdc6c69272.tar.gz
w3m-2a4a2fb9f116b50e7c80d573db06c0fdc6c69272.zip
Prevent infinite recursion with nested table and textarea
Bug-Debian: https://github.com/tats/w3m/issues/20#issuecomment-260590257
Diffstat (limited to 'table.c')
-rw-r--r--table.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/table.c b/table.c
index 33593b1..2c5c36d 100644
--- a/table.c
+++ b/table.c
@@ -1623,6 +1623,15 @@ get_table_width(struct table *t, short *orgwidth, short *cellwidth, int flag)
#define fixed_table_width(t)\
(get_table_width(t,t->fixed_width,t->cell.fixed_width,CHECK_MINIMUM))
+#define MAX_COTABLE_LEVEL 100
+static int cotable_level;
+
+void
+initRenderTable(void)
+{
+ cotable_level = 0;
+}
+
void
renderCoTable(struct table *tbl, int maxlimit)
{
@@ -1633,6 +1642,10 @@ renderCoTable(struct table *tbl, int maxlimit)
int i, col, row;
int indent, maxwidth;
+ if (cotable_level >= MAX_COTABLE_LEVEL)
+ return; /* workaround to prevent infinite recursion */
+ cotable_level++;
+
for (i = 0; i < tbl->ntable; i++) {
t = tbl->tables[i].ptr;
col = tbl->tables[i].col;