avoid accessing a temp QString via QStringView after it is deleted
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Tue, 14 May 2024 14:09:16 +0000 (16:09 +0200)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Wed, 15 May 2024 12:34:46 +0000 (14:34 +0200)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/csync/csync_exclude.cpp

index 4d2c58cb326c8d5e78695804ed1c440eb04259d0..a0411e7f5c3d4b492204b917f2253c80b42083e6 100644 (file)
@@ -134,9 +134,9 @@ static CSYNC_EXCLUDE_TYPE _csync_excluded_common(const QString &path, bool exclu
 {
     /* split up the path */
     QStringView bname(path);
-    int lastSlash = path.lastIndexOf(QLatin1Char('/'));
+    int lastSlash = bname.lastIndexOf(QLatin1Char('/'));
     if (lastSlash >= 0) {
-        bname = path.mid(lastSlash + 1);
+        bname = bname.mid(lastSlash + 1);
     }
 
     qsizetype blen = bname.size();