Jump to content

[41.78.16] File writers can be initialized with null


omiyomy

Recommended Posts

In the global getFileWriter function, if something goes wrong when creating the internal PrintWriter (or the FileOutputStream & OutputStreamWriter for that PrintWriter), it logs the error but still returns a LuaFileWriter. In this case, the PrintWriter passed to the LuaFileWriter is null. From the perspective of the calling code, this appears to be a success since the return value has no indication of an error, but the LuaFileWriter throws a NullPointerException whenever one of its methods is called.

 

This function should probably return nil in this case. Alternatively, LuaFileWriter could have a method for determining whether the writer is actually available. The same problem exists in getSandboxFileWriter.

 

This applies to both singleplayer and multiplayer. Exposed via a mod, but could occur with vanilla calls to these global functions.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...