This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Coverity: CID 1426868/1426867: Null pointer dereferences in textio.c
Type: Stage: resolved
Components: IO Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: methane, vstinner
Priority: normal Keywords: patch

Created on 2017-12-21 20:50 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4971 merged methane, 2017-12-22 07:51
Messages (2)
msg308903 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-12-21 20:50
The following warning may have been introduced by the commit 507434fd504f3ebc1da72aa77544edc0d73f136e from bpo-15216.

New defect(s) Reported-by: Coverity Scan
Showing 2 of 2 defect(s)


** CID 1426868:  Null pointer dereferences  (NULL_RETURNS)
/Modules/_io/textio.c: 1251 in textiowrapper_change_encoding()

________________________________________________________________________________________________________
*** CID 1426868:  Null pointer dereferences  (NULL_RETURNS)
/Modules/_io/textio.c: 1251 in textiowrapper_change_encoding()
1245             encoding = self->encoding;
1246             if (errors == Py_None) {
1247                 errors = self->errors;
1248             }
1249         }
1250         else if (errors == Py_None) {
>>>     CID 1426868:  Null pointer dereferences  (NULL_RETURNS)
>>>     Assigning: "errors" = null return value from "_PyUnicode_FromId".
1251             errors = _PyUnicode_FromId(&PyId_strict);
1252         }
1253
1254         const char *c_errors = PyUnicode_AsUTF8(errors);
1255         if (c_errors == NULL) {
1256             return -1;

** CID 1426867:  Null pointer dereferences  (NULL_RETURNS)
/Modules/_io/textio.c: 1153 in _io_TextIOWrapper___init___impl()


________________________________________________________________________________________________________
*** CID 1426867:  Null pointer dereferences  (NULL_RETURNS)
/Modules/_io/textio.c: 1153 in _io_TextIOWrapper___init___impl()
1147         }
1148
1149         /* XXX: Failures beyond this point have the potential to leak elements
1150          * of the partially constructed object (like self->encoding)
1151          */
1152
>>>     CID 1426867:  Null pointer dereferences  (NULL_RETURNS)
>>>     Dereferencing a null pointer "errors".
1153         Py_INCREF(errors);
1154         self->errors = errors;
1155         self->chunk_size = 8192;
1156         self->line_buffering = line_buffering;
1157         self->write_through = write_through;
1158         if (set_newline(self, newline) < 0) {
msg308976 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2017-12-24 01:29
New changeset 4856b0f34a6f4074cd86e66f11a635422374ae98 by INADA Naoki in branch 'master':
bpo-32402: io: Add missing NULL check. (GH-4971)
https://github.com/python/cpython/commit/4856b0f34a6f4074cd86e66f11a635422374ae98
History
Date User Action Args
2022-04-11 14:58:55adminsetgithub: 76583
2017-12-25 12:23:25methanesetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-12-24 01:29:23methanesetmessages: + msg308976
2017-12-22 07:51:50methanesetkeywords: + patch
stage: patch review
pull_requests: + pull_request4862
2017-12-21 20:50:02vstinnercreate