Create a copy before returning

This commit is contained in:
Mygod
2018-10-04 16:41:19 +08:00
parent e85d792218
commit 89234b37a4

View File

@@ -61,8 +61,7 @@ object TrafficRecorder {
private fun doUpdate(timestamp: Long) { private fun doUpdate(timestamp: Long) {
val oldRecords = LongSparseArray<TrafficRecord>() val oldRecords = LongSparseArray<TrafficRecord>()
loop@ for (line in RootSession.use { it.execOutUnjoined("$IPTABLES -nvx -L vpnhotspot_fwd") } loop@ for (line in RootSession.use { it.execOutUnjoined("$IPTABLES -nvx -L vpnhotspot_fwd").drop(2) }) {
.asSequence().drop(2)) {
val columns = line.split("\\s+".toRegex()).filter { it.isNotEmpty() } val columns = line.split("\\s+".toRegex()).filter { it.isNotEmpty() }
try { try {
check(columns.size >= 9) check(columns.size >= 9)