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
42858000
Commit
42858000
authored
Nov 20, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Plain Diff
Issue #28715: Added error checks for PyUnicode_AsUTF8().
parents
ed8f42c2
019d472c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
10 deletions
+20
-10
Modules/_ctypes/_ctypes.c
Modules/_ctypes/_ctypes.c
+2
-3
Modules/_ctypes/callproc.c
Modules/_ctypes/callproc.c
+3
-1
Modules/ossaudiodev.c
Modules/ossaudiodev.c
+6
-3
Python/ast.c
Python/ast.c
+5
-3
Python/importdl.c
Python/importdl.c
+4
-0
No files found.
Modules/_ctypes/_ctypes.c
View file @
42858000
...
...
@@ -728,8 +728,7 @@ PyCStructType_setattro(PyObject *self, PyObject *key, PyObject *value)
return
-
1
;
if
(
value
&&
PyUnicode_Check
(
key
)
&&
/* XXX struni _PyUnicode_AsString can fail (also in other places)! */
0
==
strcmp
(
_PyUnicode_AsString
(
key
),
"_fields_"
))
_PyUnicode_EqualToASCIIString
(
key
,
"_fields_"
))
return
PyCStructUnionType_update_stgdict
(
self
,
value
,
1
);
return
0
;
}
...
...
@@ -743,7 +742,7 @@ UnionType_setattro(PyObject *self, PyObject *key, PyObject *value)
return
-
1
;
if
(
PyUnicode_Check
(
key
)
&&
0
==
strcmp
(
_PyUnicode_AsString
(
key
)
,
"_fields_"
))
_PyUnicode_EqualToASCIIString
(
key
,
"_fields_"
))
return
PyCStructUnionType_update_stgdict
(
self
,
value
,
0
);
return
0
;
}
...
...
Modules/_ctypes/callproc.c
View file @
42858000
...
...
@@ -1666,7 +1666,9 @@ POINTER(PyObject *self, PyObject *cls)
return
result
;
}
if
(
PyUnicode_CheckExact
(
cls
))
{
char
*
name
=
_PyUnicode_AsString
(
cls
);
const
char
*
name
=
PyUnicode_AsUTF8
(
cls
);
if
(
name
==
NULL
)
return
NULL
;
buf
=
PyMem_Malloc
(
strlen
(
name
)
+
3
+
1
);
if
(
buf
==
NULL
)
return
PyErr_NoMemory
();
...
...
Modules/ossaudiodev.c
View file @
42858000
...
...
@@ -929,11 +929,14 @@ static PyMethodDef oss_mixer_methods[] = {
static
PyObject
*
oss_getattro
(
oss_audio_t
*
self
,
PyObject
*
nameobj
)
{
char
*
name
=
""
;
c
onst
c
har
*
name
=
""
;
PyObject
*
rval
=
NULL
;
if
(
PyUnicode_Check
(
nameobj
))
name
=
_PyUnicode_AsString
(
nameobj
);
if
(
PyUnicode_Check
(
nameobj
))
{
name
=
PyUnicode_AsUTF8
(
nameobj
);
if
(
name
==
NULL
)
return
NULL
;
}
if
(
strcmp
(
name
,
"closed"
)
==
0
)
{
rval
=
(
self
->
fd
==
-
1
)
?
Py_True
:
Py_False
;
...
...
Python/ast.c
View file @
42858000
...
...
@@ -2118,17 +2118,19 @@ ast_for_atom(struct compiling *c, const node *n)
errtype
=
"value error"
;
if
(
errtype
)
{
char
buf
[
128
];
const
char
*
s
=
NULL
;
PyObject
*
type
,
*
value
,
*
tback
,
*
errstr
;
PyErr_Fetch
(
&
type
,
&
value
,
&
tback
);
errstr
=
PyObject_Str
(
value
);
if
(
errstr
)
{
char
*
s
=
_PyUnicode_AsString
(
errstr
);
if
(
errstr
)
s
=
PyUnicode_AsUTF8
(
errstr
);
if
(
s
)
{
PyOS_snprintf
(
buf
,
sizeof
(
buf
),
"(%s) %s"
,
errtype
,
s
);
Py_DECREF
(
errstr
);
}
else
{
PyErr_Clear
();
PyOS_snprintf
(
buf
,
sizeof
(
buf
),
"(%s) unknown error"
,
errtype
);
}
Py_XDECREF
(
errstr
);
ast_error
(
c
,
n
,
buf
);
Py_DECREF
(
type
);
Py_XDECREF
(
value
);
...
...
Python/importdl.c
View file @
42858000
...
...
@@ -147,6 +147,10 @@ _PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *fp)
/* Package context is needed for single-phase init */
oldcontext
=
_Py_PackageContext
;
_Py_PackageContext
=
PyUnicode_AsUTF8
(
name_unicode
);
if
(
_Py_PackageContext
==
NULL
)
{
_Py_PackageContext
=
oldcontext
;
goto
error
;
}
m
=
p0
();
_Py_PackageContext
=
oldcontext
;
...
...
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