mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-09 23:38:04 -04:00
#3509 fix ByteBufInputStream memory leak
This commit is contained in:
parent
6a8cb64f46
commit
6aee1d645f
@ -26,13 +26,18 @@ abstract class PacketHandler {
|
|||||||
// Don't crash on badly formatted packets (may have been altered by a
|
// Don't crash on badly formatted packets (may have been altered by a
|
||||||
// malicious client, in which case we don't want to allow it to kill the
|
// malicious client, in which case we don't want to allow it to kill the
|
||||||
// server like this). Just spam the log a bit... ;)
|
// server like this). Just spam the log a bit... ;)
|
||||||
|
var stream: InputStream = null
|
||||||
try {
|
try {
|
||||||
val stream = new ByteBufInputStream(data)
|
stream = new ByteBufInputStream(data)
|
||||||
if (stream.read() == 0) dispatch(new PacketParser(stream, player))
|
if (stream.read() != 0) stream = new InflaterInputStream(stream)
|
||||||
else dispatch(new PacketParser(new InflaterInputStream(stream), player))
|
dispatch(new PacketParser(stream, player))
|
||||||
} catch {
|
} catch {
|
||||||
case e: Throwable =>
|
case e: Throwable =>
|
||||||
OpenComputers.log.warn("Received a badly formatted packet.", e)
|
OpenComputers.log.warn("Received a badly formatted packet.", e)
|
||||||
|
} finally {
|
||||||
|
if (stream != null) {
|
||||||
|
stream.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Avoid AFK kicks by marking players as non-idle when they send packets.
|
// Avoid AFK kicks by marking players as non-idle when they send packets.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user