Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
40db90c1
Commit
40db90c1
authored
Apr 20, 2017
by
Serhiy Storchaka
Committed by
GitHub
Apr 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-29802: Fix reference counting in module-level struct functions (#1213)
when pass arguments of wrong type.
parent
8f5cdfa9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
0 deletions
+15
-0
Lib/test/test_struct.py
Lib/test/test_struct.py
+10
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_struct.c
Modules/_struct.c
+1
-0
Objects/unicodeobject.c
Objects/unicodeobject.c
+1
-0
No files found.
Lib/test/test_struct.py
View file @
40db90c1
...
...
@@ -599,6 +599,16 @@ class StructTest(unittest.TestCase):
'
offset
-
11
out
of
range
for
10
-
byte
buffer
'):
struct.pack_into('
<
B', byte_list, -11, 123)
def test_issue29802(self):
# When the second argument of struct.unpack() was of wrong type
# the Struct object was decrefed twice and the reference to
# deallocated object was left in a cache.
with self.assertRaises(TypeError):
struct.unpack(b'b', 0)
# Shouldn'
t
crash
.
self
.
assertEqual
(
struct
.
unpack
(
b'b'
,
b'a'
),
(
b'a'
[
0
],))
class
UnpackIteratorTest
(
unittest
.
TestCase
):
"""
Tests for iterative unpacking (struct.Struct.iter_unpack).
...
...
Misc/NEWS
View file @
40db90c1
...
...
@@ -317,6 +317,9 @@ Extension Modules
Library
-------
- bpo-29802: Fixed reference counting in module-level struct functions when
pass arguments of wrong type.
- bpo-30070: Fixed leaks and crashes in errors handling in the parser module.
- bpo-22352: Column widths in the output of dis.dis() are now adjusted for
...
...
Modules/_struct.c
View file @
40db90c1
...
...
@@ -2083,6 +2083,7 @@ cache_struct_converter(PyObject *fmt, PyObject **ptr)
if
(
fmt
==
NULL
)
{
Py_DECREF
(
*
ptr
);
*
ptr
=
NULL
;
return
1
;
}
...
...
Objects/unicodeobject.c
View file @
40db90c1
...
...
@@ -3907,6 +3907,7 @@ PyUnicode_FSDecoder(PyObject* arg, void* addr)
PyObject
*
output
=
NULL
;
if
(
arg
==
NULL
)
{
Py_DECREF
(
*
(
PyObject
**
)
addr
);
*
(
PyObject
**
)
addr
=
NULL
;
return
1
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment