Skip to content

Potential memory leak in Objects/bytesobject.c#101056

@RuiliF

Description

@RuiliF

Bug report

p=PyOS_double_to_string(x, type, prec, dtoa_flags, NULL);
if (p==NULL)
returnNULL;
len=strlen(p);
if (writer!=NULL){
str=_PyBytesWriter_Prepare(writer, str, len);
if (str==NULL)
returnNULL;
memcpy(str, p, len);
PyMem_Free(p);
str+=len;
returnstr;
}

At line 438, object p won't be freed if _PyBytesWriter_Prepare fails (returns NULL) and thus become a memory leak.

Linked PRs

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