on master help sign in
Don't buffer overrun with a wild closing tag
commit5eed5e96fd27859b7875e1d10f08f2cc2e14b782 authorNeil Mitchell <ndmitchell@gmail.com> dateThu 4 Jan 2018, 22:50 (9 years ago) parent107a5dd
1 file changed+2
gen/test.c+2
gen/test.c+2
@@ -337,6 +337,8 @@ static inline str gap(const char* ref, const char* start, const char* end)
337337 me->outer = gap(d->body, tag_start, tag_start);
338338#define P_TagClose \
339339 str nodes = node_commit(&d->nodes); \
340+ if (d->nodes.used_back == 0) \
341+ return "Closing tag with no openning"; \
340342 me = &d->nodes.nodes[d->nodes.size - d->nodes.used_back]; \
341343 me->nodes = nodes; \
342344 if (me->name.length != gap(d->body, name_start, name_end).length || \