Browse Source

Squash a memory leak.

tags/v0.3
Ben Kurtovic 11 years ago
parent
commit
f1b95758d6
1 changed files with 9 additions and 6 deletions
  1. +9
    -6
      mwparserfromhell/parser/tokenizer.c

+ 9
- 6
mwparserfromhell/parser/tokenizer.c View File

@@ -1005,12 +1005,13 @@ static int
Tokenizer_handle_free_link_text(Tokenizer* self, int* parens, Tokenizer_handle_free_link_text(Tokenizer* self, int* parens,
Textbuffer** tail, Py_UNICODE this) 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)) { if (this == *"(" && !(*parens)) {
@@ -1172,6 +1173,7 @@ static int Tokenizer_parse_external_link(Tokenizer* self, int brackets)
if (!brackets) { if (!brackets) {
if (Tokenizer_remove_uri_scheme_from_textbuffer(self, link)) { if (Tokenizer_remove_uri_scheme_from_textbuffer(self, link)) {
Textbuffer_dealloc(extra); Textbuffer_dealloc(extra);
Py_DECREF(link);
return -1; return -1;
} }
} }
@@ -1199,6 +1201,7 @@ static int Tokenizer_parse_external_link(Tokenizer* self, int brackets)
} }
if (extra->size || extra->next) if (extra->size || extra->next)
return Tokenizer_emit_textbuffer(self, extra, 0); return Tokenizer_emit_textbuffer(self, extra, 0);
Textbuffer_dealloc(extra);
return 0; return 0;
} }




Loading…
Cancel
Save