Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Modules/_elementtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -4285,6 +4285,9 @@ _elementtree_XMLParser__setevents_impl(XMLParserObject *self,
if (events_to_report == Py_None) {
/* default is "end" only */
self->end_event_obj = PyUnicode_FromString("end");
if (self->end_event_obj == NULL) {
return NULL;
}
Py_RETURN_NONE;
}

Expand Down
4 changes: 4 additions & 0 deletions Modules/_io/winconsoleio.c
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,10 @@ _io__WindowsConsoleIO_readall_impl(winconsoleio *self)

bytes_size += _buflen(self);
bytes = PyBytes_FromStringAndSize(NULL, bytes_size);
if (bytes == NULL) {
PyMem_Free(buf);
return NULL;
}
rn = _copyfrombuf(self, PyBytes_AS_STRING(bytes), bytes_size);

if (len) {
Expand Down
3 changes: 3 additions & 0 deletions Modules/_testinternalcapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2625,6 +2625,9 @@ get_crossinterp_data(PyObject *self, PyObject *args, PyObject *kwargs)
}
else {
mode = PyUnicode_AsUTF8(modeobj);
if (mode == NULL) {
return NULL;
}
if (strlen(mode) == 0) {
mode = "xidata";
}
Expand Down
4 changes: 4 additions & 0 deletions Modules/_xxtestfuzz/fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ static int fuzz_sre_match(const char* data, size_t size) {

PyObject* pattern = compiled_patterns[idx];
PyObject* match_callable = PyObject_GetAttrString(pattern, "match");
if (match_callable == NULL) {
Py_DECREF(to_match);
return 0;
}

PyObject* matches = PyObject_CallOneArg(match_callable, to_match);

Expand Down
6 changes: 5 additions & 1 deletion Modules/getpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,11 @@ getpath_warn(PyObject *Py_UNUSED(self), PyObject *args)
if (!PyArg_ParseTuple(args, "U", &msgobj)) {
return NULL;
}
fprintf(stderr, "%s\n", PyUnicode_AsUTF8(msgobj));
const char *msg = PyUnicode_AsUTF8(msgobj);
if (msg == NULL) {
return NULL;
}
fprintf(stderr, "%s\n", msg);
Py_RETURN_NONE;
}

Expand Down
3 changes: 2 additions & 1 deletion Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5675,8 +5675,9 @@ os__getvolumepathname_impl(PyObject *module, path_t *path)
goto exit;
}
result = PyUnicode_FromWideChar(mountpath, -1);
if (PyBytes_Check(path->object))
if (result != NULL && PyBytes_Check(path->object)) {
Py_SETREF(result, PyUnicode_EncodeFSDefault(result));
}

exit:
PyMem_Free(mountpath);
Expand Down
17 changes: 13 additions & 4 deletions Modules/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -1508,10 +1508,19 @@ flex_complete(const char *text, int start, int end)

done:
if (state) {
Py_XDECREF(state->begidx);
Py_XDECREF(state->endidx);
state->begidx = PyLong_FromLong((long) start);
state->endidx = PyLong_FromLong((long) end);
PyObject *begidx = PyLong_FromLong((long) start);
PyObject *endidx = PyLong_FromLong((long) end);
if (begidx == NULL || endidx == NULL) {
Py_XDECREF(begidx);
Py_XDECREF(endidx);
PyErr_FormatUnraisable("Exception ignored while preparing "
"readline completion");
rl_attempted_completion_over = 1;
PyGILState_Release(gilstate);
return NULL;
}
Py_XSETREF(state->begidx, begidx);
Py_XSETREF(state->endidx, endidx);
}
result = completion_matches((char *)text, *on_completion);
PyGILState_Release(gilstate);
Expand Down
3 changes: 3 additions & 0 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1786,6 +1786,9 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
PyObject *vmId = PyUnicode_FromWideChar(guidStr, -1);
res = RpcStringFreeW(&guidStr);
assert(res == RPC_S_OK);
if (vmId == NULL) {
return 0;
}

res = UuidToStringW(&a->ServiceId, &guidStr);
if (res != RPC_S_OK) {
Expand Down
16 changes: 16 additions & 0 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1225,8 +1225,16 @@ dtrace_function_entry(_PyInterpreterFrame *frame)
int lineno;

PyCodeObject *code = _PyFrame_GetCode(frame);
PyObject *exc = PyErr_GetRaisedException();
filename = PyUnicode_AsUTF8(code->co_filename);
funcname = PyUnicode_AsUTF8(code->co_name);
PyErr_SetRaisedException(exc);
if (filename == NULL) {
filename = "<unknown>";
}
if (funcname == NULL) {
funcname = "<unknown>";
}
lineno = PyUnstable_InterpreterFrame_GetLine(frame);

PyDTrace_FUNCTION_ENTRY(filename, funcname, lineno);
Expand All @@ -1240,8 +1248,16 @@ dtrace_function_return(_PyInterpreterFrame *frame)
int lineno;

PyCodeObject *code = _PyFrame_GetCode(frame);
PyObject *exc = PyErr_GetRaisedException();
filename = PyUnicode_AsUTF8(code->co_filename);
funcname = PyUnicode_AsUTF8(code->co_name);
PyErr_SetRaisedException(exc);
if (filename == NULL) {
filename = "<unknown>";
}
if (funcname == NULL) {
funcname = "<unknown>";
}
lineno = PyUnstable_InterpreterFrame_GetLine(frame);

PyDTrace_FUNCTION_RETURN(filename, funcname, lineno);
Expand Down
5 changes: 5 additions & 0 deletions Python/crossinterp.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,11 @@ check_missing___main___attr(PyObject *exc)
}
}
const char *err = PyUnicode_AsUTF8(msgobj);
if (err == NULL) {
PyErr_Clear();
Py_DECREF(msgobj);
return 0;
}

// Check if it's a missing __main__ attr.
int cmp = strncmp(err, "module '__main__' has no attribute '", 36);
Expand Down
Loading