Fix excessive reference counting on faked string .decode()

This commit is contained in:
Panu Matilainen 2019-04-11 10:38:45 +03:00
parent d4f7fd8c04
commit c7bd807f7c
2 changed files with 5 additions and 3 deletions

View File

@ -52,7 +52,7 @@ diff --git a/python/rpmsystem-py.h b/python/rpmsystem-py.h
index 25938464a..803da0fc1 100644
--- a/python/rpmsystem-py.h
+++ b/python/rpmsystem-py.h
@@ -19,12 +19,30 @@
@@ -19,12 +19,29 @@
#define PyInt_AsSsize_t PyLong_AsSsize_t
#endif
@ -76,7 +76,6 @@ index 25938464a..803da0fc1 100644
+ Py_DECREF(n);
+ }
+ if (fakedecode && o) {
+ Py_INCREF(fakedecode);
+ /* monkey-patch it into the string object as "decode" */
+ PyDict_SetItemString(Py_TYPE(o)->tp_dict, "decode", fakedecode);
+ }

View File

@ -23,7 +23,7 @@
%global rpmver 4.14.2.1
#global snapver rc2
%global rel 6
%global rel 7
%global srcver %{version}%{?snapver:-%{snapver}}
%global srcdir %{?snapver:testing}%{!?snapver:%{name}-%(echo %{version} | cut -d'.' -f1-2).x}
@ -576,6 +576,9 @@ make check || (cat tests/rpmtests.log; exit 1)
%doc doc/librpm/html/*
%changelog
* Thu Apr 11 2019 Panu Matilainen <pmatilai@redhat.com> - 4.14.2.1-7
- Fix excessive reference counting on faked string .decode()
* Wed Apr 10 2019 Panu Matilainen <pmatilai@redhat.com> - 4.14.2.1-6
- Unbreak Python 3 API by returning string data as surrogate-escaped utf-8
string objects instead of bytes (#1693751)