Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dangling pointer in Gadget_List_Box_Add_Multi_Select #1098

Open
xezon opened this issue Feb 8, 2024 · 0 comments
Open

Dangling pointer in Gadget_List_Box_Add_Multi_Select #1098

xezon opened this issue Feb 8, 2024 · 0 comments

Comments

@xezon
Copy link
Contributor

xezon commented Feb 8, 2024

void Gadget_List_Box_Add_Multi_Select(GameWindow *list_box)
{
    _ListboxData *data = static_cast<_ListboxData *>(list_box->Win_Get_User_Data());
    captainslog_dbgassert(data != nullptr && data->m_selections == nullptr, "selections is not NULL");
    data->m_selections = new int[data->m_listLength];
    captainslog_debug("Enable list box multi select: listLength (select) = %d * %d = %d bytes;",
        data->m_listLength,
        sizeof(int),
        sizeof(int) * data->m_listLength);

    if (data->m_selections != nullptr) {
        memset(data->m_selections, -1, sizeof(int) * data->m_listLength);
        data->m_multiSelect = 1;
        list_box->Win_Set_Input_Func(Gadget_List_Box_Multi_Input);
    } else {
        delete data->m_listData;
    }
}

delete data->m_listData; needs to be followed by
data->m_listData = nullptr;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant