6822: Fix editor crashes with quad point and other popup menus r=def- a=Robyt3

Closes #6817.

## Checklist

- [X] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
bors[bot] 2023-07-08 09:59:01 +00:00 committed by GitHub
commit 43324d4d57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View file

@ -6577,12 +6577,9 @@ void CEditor::RenderMousePointer()
void CEditor::Reset(bool CreateDefault)
{
UI()->ClosePopupMenus();
m_Map.Clean();
//delete undo file
char aBuffer[1024];
m_pStorage->GetCompletePath(IStorage::TYPE_SAVE, "editor/", aBuffer, sizeof(aBuffer));
mem_zero(m_apSavedBrushes, sizeof m_apSavedBrushes);
// create default layers

View file

@ -1199,6 +1199,8 @@ CUI::EPopupMenuFunctionResult CEditor::PopupPoint(void *pContext, CUIRect View,
{
CEditor *pEditor = static_cast<CEditor *>(pContext);
std::vector<CQuad *> vpQuads = pEditor->GetSelectedQuads();
if(!in_range<int>(pEditor->m_SelectedQuadIndex, 0, vpQuads.size() - 1))
return CUI::POPUP_CLOSE_CURRENT;
CQuad *pCurrentQuad = vpQuads[pEditor->m_SelectedQuadIndex];
enum