Skip to content

Commit 28d2907

Browse files
committed
fix: ref leak on invalid objects inside iterator
1 parent 3bdfd78 commit 28d2907

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/PyRouter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,10 @@ PyObject* PyRouter::route(PyRouter* self, PyObject* const* args,
223223

224224
Py_ssize_t sz;
225225
const char* c {PyUnicode_AsUTF8AndSize(next, &sz)};
226-
if(!c)
226+
if(!c) {
227+
Py_DECREF(next);
227228
return nullptr;
229+
}
228230

229231
auto hash {HTTPPerfectHash::in_word_set(c, static_cast<std::size_t>(sz))};
230232
if(hash == nullptr) {

0 commit comments

Comments
 (0)