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

Correctly validate CourseMap getters #130

Open
vabold opened this issue Jul 17, 2024 · 0 comments
Open

Correctly validate CourseMap getters #130

vabold opened this issue Jul 17, 2024 · 0 comments
Labels
bug Something isn't working engine Code involving engine (C++) P3 Priority: Low

Comments

@vabold
Copy link
Owner

vabold commented Jul 17, 2024

Currently, we have:

MapdataStartPoint *CourseMap::getStartPoint(u16 i) const {
    return m_startPoint && m_startPoint->size() != 0 ? m_startPoint->get(i) : nullptr;
}

In reality, this is calling an inlined function to get the count of MapdataStartPoint instances in the accessor, which should look like this:

u16 CourseMap::getStartPointCount() const {
    return m_startPoint ? m_startPoint->size() : 0;
}

And in the base game, we should be comparing i against this count:

MapdataStartPoint *CourseMap::getStartPoint(u16 i) const {
    return i < getStartPointCount() ? m_startPoint->get(i) : nullptr;
}
@vabold vabold added bug Something isn't working engine Code involving engine (C++) P3 Priority: Low labels Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working engine Code involving engine (C++) P3 Priority: Low
Projects
None yet
Development

No branches or pull requests

1 participant