Skip to content

Commit

Permalink
Squash a memory leak.
Browse files Browse the repository at this point in the history
  • Loading branch information
earwig committed Aug 23, 2013
1 parent 2561cf5 commit f1b9575
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions mwparserfromhell/parser/tokenizer.c
Expand Up @@ -1005,12 +1005,13 @@ static int
Tokenizer_handle_free_link_text(Tokenizer* self, int* parens,
Textbuffer** tail, Py_UNICODE this)
{
#define PUSH_TAIL_BUFFER(tail, error) \
if ((tail)->size || (tail)->next) { \
Tokenizer_emit_textbuffer(self, tail, 0); \
tail = Textbuffer_new(); \
if (!(tail)) \
return error; \
#define PUSH_TAIL_BUFFER(tail, error) \
if ((tail)->size || (tail)->next) { \
if (Tokenizer_emit_textbuffer(self, tail, 0)) \
return error; \
tail = Textbuffer_new(); \
if (!(tail)) \
return error; \
}

if (this == *"(" && !(*parens)) {
Expand Down Expand Up @@ -1172,6 +1173,7 @@ static int Tokenizer_parse_external_link(Tokenizer* self, int brackets)
if (!brackets) {
if (Tokenizer_remove_uri_scheme_from_textbuffer(self, link)) {
Textbuffer_dealloc(extra);
Py_DECREF(link);
return -1;
}
}
Expand Down Expand Up @@ -1199,6 +1201,7 @@ static int Tokenizer_parse_external_link(Tokenizer* self, int brackets)
}
if (extra->size || extra->next)
return Tokenizer_emit_textbuffer(self, extra, 0);
Textbuffer_dealloc(extra);
return 0;
}

Expand Down

0 comments on commit f1b9575

Please sign in to comment.