Browse Source

Add guard against a rare crash in the C tokenizer

tags/v0.5.4
Ben Kurtovic 5 years ago
parent
commit
8c5f554406
3 changed files with 12 additions and 4 deletions
  1. +3
    -2
      CHANGELOG
  2. +3
    -2
      docs/changelog.rst
  3. +6
    -0
      mwparserfromhell/parser/ctokenizer/tok_parse.c

+ 3
- 2
CHANGELOG View File

@@ -1,6 +1,7 @@
v0.6 (unreleased):
v0.5.4 (unreleased):


- ...
- Fixed an unlikely crash in the C tokenizer when interrupted while parsing
a heading.


v0.5.3 (released March 30, 2019): v0.5.3 (released March 30, 2019):




+ 3
- 2
docs/changelog.rst View File

@@ -1,13 +1,14 @@
Changelog Changelog
========= =========


v0.6
v0.5.4
---- ----


Unreleased Unreleased
(`changes <https://github.com/earwig/mwparserfromhell/compare/v0.5.3...develop>`__): (`changes <https://github.com/earwig/mwparserfromhell/compare/v0.5.3...develop>`__):


- ...
- Fixed an unlikely crash in the C tokenizer when interrupted while parsing
a heading.


v0.5.3 v0.5.3
------ ------


+ 6
- 0
mwparserfromhell/parser/ctokenizer/tok_parse.c View File

@@ -813,6 +813,9 @@ static int Tokenizer_parse_heading(Tokenizer* self)
self->global ^= GL_HEADING; self->global ^= GL_HEADING;
return 0; return 0;
} }
if (!heading) {
return -1;
}
#ifdef IS_PY3K #ifdef IS_PY3K
level = PyLong_FromSsize_t(heading->level); level = PyLong_FromSsize_t(heading->level);
#else #else
@@ -892,6 +895,9 @@ static HeadingData* Tokenizer_handle_heading_end(Tokenizer* self)
self->head = reset + best - 1; self->head = reset + best - 1;
} }
else { else {
if (!after) {
return NULL;
}
for (i = 0; i < best; i++) { for (i = 0; i < best; i++) {
if (Tokenizer_emit_char(self, '=')) { if (Tokenizer_emit_char(self, '=')) {
Py_DECREF(after->title); Py_DECREF(after->title);


Loading…
Cancel
Save