Skip to content

GUI editor crashes engine when attempting to save outside of the program directory. #2381

Description

@chaigler

This is on Windows, although something similar may happen on Mac and Linux. May also affect the mission editor (I haven't tried that yet).

If you attempt to save a GUI to a location outside of the main program directory the engine will crash and point to Stream::_write() with a 'Read Access Violation: this was nullptr' error. This occurs because the FileObject used in GuiEditCanvas::save() fails to open the location for writing (unless you're running the program as an admin/have elevated permissions) and the save() method doesn't check its return value to make sure it can actually write the data.

I've patched this in my repo by simply checking the return val & exiting the save() method early if it's false (around line 439 in guiEditorCanvas.ed.cs):

if(!%fo.openForWrite(%filename))
{
    error("GuiEditCanvas::save() - Unable to save, file location not open for writing.");
    %fo.close();
         
    return false;
}
      

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions