Skip to content

GadgetListBoxSetListLength uses Int as new length but Short as internal length #3163

Description

@stephanmeesters

Suspicious code. listboxData->listLength which is Short is compared and assigned to Int newLength

void GadgetListBoxSetListLength( GameWindow *listbox, Int newLength )
{
ListboxData *listboxData = (ListboxData *)listbox->winGetUserData();
// ListboxData *listboxData = (ListboxData *)listbox->winGetUserData();
// ListEntry *newData = (ListEntry *)malloc(newLength * sizeof(ListEntry));
DEBUG_ASSERTCRASH(listboxData, ("We don't have our needed listboxData!"));
if( !listboxData )
return;
DEBUG_ASSERTCRASH(listboxData->columns > 0,("We need at least one Column in the listbox"));
if( listboxData->columns < 1 )
return;
Int columns = listboxData->columns;
ListEntryRow *newData = NEW ListEntryRow[ newLength ];
DEBUG_ASSERTCRASH(newData, ("Unable to allocate new data structures for the Listbox"));
if( !newData )
return;
Int i;
// zero out the new Data structure
memset( newData, 0, newLength * sizeof( ListEntryRow ) );
// we want to copy over different amounts of data depending on if we're adding
// to the list box or removing from the listbox
if(newLength >= listboxData->listLength)
{
memcpy(newData,listboxData->listData,listboxData->listLength * sizeof( ListEntryRow ) );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions