python / cpython

The Python programming language
https://www.python.org
Other
63.42k stars 30.37k forks source link

Coverity: CID 1428443: Null pointer dereferences (NULL_RETURNS) /Python/hamt.c: 1058 in hamt_node_bitmap_without() #76820

Closed vstinner closed 6 years ago

vstinner commented 6 years ago
BPO 32639
Nosy @vstinner, @1st1

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: ```python assignee = None closed_at = created_at = labels = ['interpreter-core', 'type-bug', '3.7'] title = 'Coverity: CID 1428443: Null pointer dereferences (NULL_RETURNS) /Python/hamt.c: 1058 in hamt_node_bitmap_without()' updated_at = user = 'https://github.com/vstinner' ``` bugs.python.org fields: ```python activity = actor = 'yselivanov' assignee = 'none' closed = True closed_date = closer = 'yselivanov' components = ['Interpreter Core'] creation = creator = 'vstinner' dependencies = [] files = [] hgrepos = [] issue_num = 32639 keywords = [] message_count = 4.0 messages = ['310522', '310524', '310526', '310527'] nosy_count = 2.0 nosy_names = ['vstinner', 'yselivanov'] pr_nums = [] priority = 'normal' resolution = 'out of date' stage = 'resolved' status = 'closed' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue32639' versions = ['Python 3.7'] ```

vstinner commented 6 years ago

Coverity found a bug in hamt.c:

** CID 1428443: Null pointer dereferences (NULL_RETURNS) /Python/hamt.c: 1058 in hamt_node_bitmap_without()

________________________________________________________________________________________________________
*** CID 1428443:  Null pointer dereferences  (NULL_RETURNS)
/Python/hamt.c: 1058 in hamt_node_bitmap_without()
1052                         assert(hamt_node_collision_count(
1053                                 (PyHamtNode_Collision*)sub_node) > 1);
1054                     }
1055     #endif
1056
1057                     PyHamtNode_Bitmap *clone = hamt_node_bitmap_clone(self);
>>>     CID 1428443:  Null pointer dereferences  (NULL_RETURNS)
>>>     Dereferencing a null pointer "clone".
1058                     Py_SETREF(clone->b_array[val_idx],
1059                               (PyObject *)sub_node);  /* borrow */
1060
1061                     *new_node = (PyHamtNode *)clone;
1062                     return W_NEWNODE;
1063                 }
1st1 commented 6 years ago

Victor, it's been already fixed/tracked here: https://github.com/python/cpython/pull/5286

(I also receive coverity reports :)

vstinner commented 6 years ago

(I also receive coverity reports :)

Oh, I didn't know. The current workflow is not ideal to avoid duplicated issues.

1st1 commented 6 years ago

Oh, I didn't know. The current workflow is not ideal to avoid duplicated issues.

If I fix something that's been reported there I usually update the coverity issue directly. But yeah...