File tree Expand file tree Collapse file tree
src/main/scala/li/cil/oc/common Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,13 +26,18 @@ abstract class PacketHandler {
2626 // Don't crash on badly formatted packets (may have been altered by a
2727 // malicious client, in which case we don't want to allow it to kill the
2828 // server like this). Just spam the log a bit... ;)
29+ var stream : InputStream = null
2930 try {
30- val stream = new ByteBufInputStream (data)
31- if (stream.read() == 0 ) dispatch( new PacketParser (stream, player) )
32- else dispatch(new PacketParser (new InflaterInputStream ( stream) , player))
31+ stream = new ByteBufInputStream (data)
32+ if (stream.read() != 0 ) stream = new InflaterInputStream (stream)
33+ dispatch(new PacketParser (stream, player))
3334 } catch {
3435 case e : Throwable =>
3536 OpenComputers .log.warn(" Received a badly formatted packet." , e)
37+ } finally {
38+ if (stream != null ) {
39+ stream.close()
40+ }
3641 }
3742
3843 // Avoid AFK kicks by marking players as non-idle when they send packets.
You can’t perform that action at this time.
0 commit comments