diff --git a/CHANGELOG b/CHANGELOG index 217ffba..7c85c2b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +v0.5.4 (released May 15, 2019): + +- Fixed an unlikely crash in the C tokenizer when interrupted while parsing + a heading. + v0.5.3 (released March 30, 2019): - Fixed manual construction of Node objects, previously unsupported. (#214) diff --git a/appveyor.yml b/appveyor.yml index 067bffb..3d738e4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,6 @@ # This config file is used by appveyor.com to build Windows release binaries -version: 0.5.3-b{build} +version: 0.5.4-b{build} branches: only: diff --git a/docs/changelog.rst b/docs/changelog.rst index afdddd6..808e9b9 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,15 @@ Changelog ========= +v0.5.4 +------ + +`Released May 15, 2019 `_ +(`changes `__): + +- Fixed an unlikely crash in the C tokenizer when interrupted while parsing + a heading. + v0.5.3 ------ diff --git a/mwparserfromhell/__init__.py b/mwparserfromhell/__init__.py index eefe79a..4e4d440 100644 --- a/mwparserfromhell/__init__.py +++ b/mwparserfromhell/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2012-2018 Ben Kurtovic +# Copyright (C) 2012-2019 Ben Kurtovic # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -27,9 +27,9 @@ outrageously powerful parser for `MediaWiki `_ wikicode. """ __author__ = "Ben Kurtovic" -__copyright__ = "Copyright (C) 2012-2018 Ben Kurtovic" +__copyright__ = "Copyright (C) 2012-2019 Ben Kurtovic" __license__ = "MIT License" -__version__ = "0.5.3" +__version__ = "0.5.4" __email__ = "ben.kurtovic@gmail.com" from . import (compat, definitions, nodes, parser, smart_list, string_mixin, diff --git a/mwparserfromhell/parser/ctokenizer/tok_parse.c b/mwparserfromhell/parser/ctokenizer/tok_parse.c index ab46252..c32e48c 100644 --- a/mwparserfromhell/parser/ctokenizer/tok_parse.c +++ b/mwparserfromhell/parser/ctokenizer/tok_parse.c @@ -813,6 +813,9 @@ static int Tokenizer_parse_heading(Tokenizer* self) self->global ^= GL_HEADING; return 0; } + if (!heading) { + return -1; + } #ifdef IS_PY3K level = PyLong_FromSsize_t(heading->level); #else @@ -892,6 +895,9 @@ static HeadingData* Tokenizer_handle_heading_end(Tokenizer* self) self->head = reset + best - 1; } else { + if (!after) { + return NULL; + } for (i = 0; i < best; i++) { if (Tokenizer_emit_char(self, '=')) { Py_DECREF(after->title);