Skip to content

Valgrind: Conditional jump or move depends on uninitialised value in ob_digit[0] of PyLongObject#119022

@OveSo

Description

@OveSo

Bug report

Bug description:

There are several cases, where ob_digit[0] of PyLongObject will not be initialized before evaluation.
I fixed that issue in Python 3.11.8 with this patch - it also concerns Python 3.11.9:

---longobject.c_orig2024-02-0622:21:21.000000000+0100+++longobject.c2024-05-1317:47:25.846011498+0200 @@ -165,6+165,7 @@ returnNULL} _PyObject_InitVar((PyVarObject*)result, &PyLong_Type, size); +result->ob_digit[0] =0; returnresult}

For example, one case is in longobject.c:922 in _PyLong_FromByteArray() if numsignificantbytes==0.
First, I fixed it locally in _PyLong_FromByteArray() but than I found similar cases in other functions.
Therefore, I decided to initialize ob_digit[0] right in _PyLong_New() in order to catch all situations.
Kind regards,
Ove

CPython versions tested on:

3.11

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions