diff options
author | Simon Rettberg | 2022-06-20 16:24:58 +0200 |
---|---|---|
committer | Simon Rettberg | 2022-06-20 16:24:58 +0200 |
commit | 58d458327ec5566d82bcb31cb73756ac455b898c (patch) | |
tree | 530176940c45244c405250b143b056c3d05e89e4 | |
parent | Was not working anymore since eth0 was renamed boot0 -.- (diff) | |
download | speedcheck-58d458327ec5566d82bcb31cb73756ac455b898c.tar.gz speedcheck-58d458327ec5566d82bcb31cb73756ac455b898c.tar.xz speedcheck-58d458327ec5566d82bcb31cb73756ac455b898c.zip |
Fix use after free
-rw-r--r-- | src/datasource/networkspeed.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/datasource/networkspeed.cpp b/src/datasource/networkspeed.cpp index 451c97e..2a67598 100644 --- a/src/datasource/networkspeed.cpp +++ b/src/datasource/networkspeed.cpp @@ -5,10 +5,11 @@ NetworkSpeed::NetworkSpeed() : _lastMs(0), _file(nullptr) { - for (QString s : QStringList() - << "/sys/class/net/boot0/statistics/rx_bytes" - << "/sys/class/net/eth0/statistics/rx_bytes" - << "/sys/class/net/br0/statistics/rx_bytes") { + QStringList list = QStringList() + << "/sys/class/net/boot0/statistics/rx_bytes" + << "/sys/class/net/eth0/statistics/rx_bytes" + << "/sys/class/net/br0/statistics/rx_bytes"; + for (QString s : list) { if (!QFile::exists(s)) continue; _file = new QFile(s); |