Skip to content

Coverity: CID 1426868/1426867: Null pointer dereferences in textio.c #76583

Closed

Description

@vstinner
BPO 32402
Nosy @vstinner, @methane
PRs
  • bpo-32402: io: Add missing NULL check. #4971
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2017-12-25.12:23:25.868>
    created_at = <Date 2017-12-21.20:50:02.178>
    labels = ['3.7', 'expert-IO']
    title = 'Coverity: CID 1426868/1426867:  Null pointer dereferences in textio.c'
    updated_at = <Date 2017-12-25.12:23:25.867>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2017-12-25.12:23:25.867>
    actor = 'methane'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-12-25.12:23:25.868>
    closer = 'methane'
    components = ['IO']
    creation = <Date 2017-12-21.20:50:02.178>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32402
    keywords = ['patch']
    message_count = 2.0
    messages = ['308903', '308976']
    nosy_count = 2.0
    nosy_names = ['vstinner', 'methane']
    pr_nums = ['4971']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue32402'
    versions = ['Python 3.7']

    Activity

    1. vstinner commented on Dec 21, 2017

      @vstinner
      MemberAuthor

      The following warning may have been introduced by the commit 507434f 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) {
    2. methane commented on Dec 24, 2017

      @methane
      Member

      New changeset 4856b0f by INADA Naoki in branch 'master':
      bpo-32402: io: Add missing NULL check. (GH-4971)
      4856b0f

    3. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions