summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2022-06-20 16:24:58 +0200
committerSimon Rettberg2022-06-20 16:24:58 +0200
commit58d458327ec5566d82bcb31cb73756ac455b898c (patch)
tree530176940c45244c405250b143b056c3d05e89e4
parentWas not working anymore since eth0 was renamed boot0 -.- (diff)
downloadspeedcheck-58d458327ec5566d82bcb31cb73756ac455b898c.tar.gz
speedcheck-58d458327ec5566d82bcb31cb73756ac455b898c.tar.xz
speedcheck-58d458327ec5566d82bcb31cb73756ac455b898c.zip
Fix use after free
-rw-r--r--src/datasource/networkspeed.cpp9
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);