Fixed two reference leaks in unknown field processing.

PiperOrigin-RevId: 449248186
pull/13171/head
Joshua Haberman 3 years ago committed by Copybara-Service
parent a60e9a379e
commit 5ae371162d
  1. 1
      python/pb_unit_tests/descriptor_pool_test_wrapper.py
  2. 3
      python/unknown_fields.c

@ -38,7 +38,6 @@ if __name__ == '__main__':
# end:github_only
# begin:google_only
# CreateDescriptorPoolTest.testComplexNestingWithProtoFileParser.__unittest_expecting_failure__ = True
# from absl import app
# if __name__ == '__main__':
# app.run(lambda argv: unittest.main(verbosity=2))

@ -184,7 +184,9 @@ done:
if (type_id && msg) {
PyObject* field = PyObject_CallFunction(
s->unknown_field_type, "iiO", type_id, kUpb_WireType_Delimited, msg);
if (!field) goto err;
PyList_Append(self->fields, field);
Py_DECREF(field);
}
Py_XDECREF(msg);
return ptr;
@ -293,6 +295,7 @@ static const char* PyUpb_UnknownFieldSet_Build(PyUpb_UnknownFieldSet* self,
PyObject* field = PyObject_CallFunction(s->unknown_field_type, "iiN",
field_number, wire_type, data);
PyList_Append(self->fields, field);
Py_DECREF(field);
}
return ptr;

Loading…
Cancel
Save