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

Editor segfaults when saving in Linux #162

Closed
cesarmiquel opened this issue Jul 10, 2022 · 2 comments · Fixed by #163
Closed

Editor segfaults when saving in Linux #162

cesarmiquel opened this issue Jul 10, 2022 · 2 comments · Fixed by #163

Comments

@cesarmiquel
Copy link
Contributor

When I try to save my work on Linux I get a segfault. I compiled the app with debug information and run with gdb to trace the error. The problem seems to be caused in src/loadave.c line 431:

#if defined(_WIN32)
    _wfopen_s(&fp, path, L"wt");
#else
    fp = fopen(path, "wt");
#endif

The problem is that fp is NULL. Upon inspecting the flags passed on to fopen() I noticed the t flag which I've never seen before. Upon looking at the documentation for fopen() I see no mention of that flag. I removed the flag (just left the standard w) and it seems to work fine. I'm submitting a patch to fix this and also check to make sure fp is non-null so that you don't loose everything if fopen() fails.

@cesarmiquel
Copy link
Contributor Author

Hmmm... checking the Windows documentation it seems that the t flag exists and is called "text-mode translation flag". I searched a bit and I can't find anywhere saying it is available in Linux. On my computer fp returns NULL and the call to mxmlSaveFile(xml, fp, whitespaceCallback) with a NULL fp segaults.

References:

@cesarmiquel
Copy link
Contributor Author

Hmm... strange. I'm not able to reproduce this. I did notice that if you try to write to a directory you don't have permissions to write to (like /) then fp will be NULL so I think this patch is harmless and makes sure rocket doesn't crash if you have permission issues. The t flag does nothing in Linux so I guess we can remove it. But it doesn't seem to crash Rocket. 🤔 why was fopen() returning NULL to me ...

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

Successfully merging a pull request may close this issue.

1 participant