瀏覽代碼

Squash a couple memory leaks.

tags/v0.3
Ben Kurtovic 11 年之前
父節點
當前提交
0d934f8ad1
共有 1 個檔案被更改,包括 12 行新增2 行删除
  1. +12
    -2
      mwparserfromhell/parser/tokenizer.c

+ 12
- 2
mwparserfromhell/parser/tokenizer.c 查看文件

@@ -1646,11 +1646,13 @@ static int Tokenizer_handle_invalid_tag_start(Tokenizer* self)
} }
if (!IS_SINGLE_ONLY(name)) if (!IS_SINGLE_ONLY(name))
FAIL_ROUTE(0); FAIL_ROUTE(0);
Py_DECREF(name);
break; break;
} }
Textbuffer_write(&buf, this); Textbuffer_write(&buf, this);
pos++; pos++;
} }
Textbuffer_dealloc(buf);
if (!BAD_ROUTE) { if (!BAD_ROUTE) {
tag = Tokenizer_really_parse_tag(self); tag = Tokenizer_really_parse_tag(self);
if (!tag) if (!tag)
@@ -1664,7 +1666,12 @@ static int Tokenizer_handle_invalid_tag_start(Tokenizer* self)
// Set invalid=True flag of TagOpenOpen // Set invalid=True flag of TagOpenOpen
if (PyObject_SetAttrString(PyList_GET_ITEM(tag, 0), "invalid", Py_True)) if (PyObject_SetAttrString(PyList_GET_ITEM(tag, 0), "invalid", Py_True))
return -1; return -1;
return Tokenizer_emit_all(self, tag);
if (Tokenizer_emit_all(self, tag)) {
Py_DECREF(tag);
return -1;
}
Py_DECREF(tag);
return 0;
} }


/* /*
@@ -1685,7 +1692,10 @@ static int Tokenizer_parse_tag(Tokenizer* self)
if (!tag) { if (!tag) {
return -1; return -1;
} }
Tokenizer_emit_all(self, tag);
if (Tokenizer_emit_all(self, tag)) {
Py_DECREF(tag);
return -1;
}
Py_DECREF(tag); Py_DECREF(tag);
return 0; return 0;
} }


Loading…
取消
儲存