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
7cac1c25
Commit
7cac1c25
authored
Mar 03, 2013
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #16445: Fix potential segmentation fault when deleting an exception message.
parent
ff0deb05
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
2 deletions
+16
-2
Lib/test/test_exceptions.py
Lib/test/test_exceptions.py
+12
-0
Misc/NEWS
Misc/NEWS
+3
-0
Objects/exceptions.c
Objects/exceptions.c
+1
-2
No files found.
Lib/test/test_exceptions.py
View file @
7cac1c25
...
...
@@ -479,6 +479,18 @@ class ExceptionTests(unittest.TestCase):
except
AssertionError
as
e
:
self
.
assertEqual
(
str
(
e
),
"(3,)"
)
def
test_bad_exception_clearing
(
self
):
# See issue 16445: use of Py_XDECREF instead of Py_CLEAR in
# BaseException_set_message gave a possible way to segfault the
# interpreter.
class
Nasty
(
str
):
def
__del__
(
message
):
del
e
.
message
e
=
ValueError
(
Nasty
(
"msg"
))
e
.
args
=
()
del
e
.
message
# Helper class used by TestSameStrAndUnicodeMsg
class
ExcWithOverriddenStr
(
Exception
):
...
...
Misc/NEWS
View file @
7cac1c25
...
...
@@ -9,6 +9,9 @@ What's New in Python 2.7.4
Core and Builtins
-----------------
- Issue #16445: Fixed potential segmentation fault when deleting an exception
message.
- Issue #17275: Corrected class name in init error messages of the C version of
BufferedWriter and BufferedRandom.
...
...
Objects/exceptions.c
View file @
7cac1c25
...
...
@@ -349,8 +349,7 @@ BaseException_set_message(PyBaseExceptionObject *self, PyObject *val)
if
(
PyDict_DelItemString
(
self
->
dict
,
"message"
)
<
0
)
return
-
1
;
}
Py_XDECREF
(
self
->
message
);
self
->
message
=
NULL
;
Py_CLEAR
(
self
->
message
);
return
0
;
}
...
...
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