Fix coverity issue (copy data during iteration) 84/297284/1
authorANZ1217 <chihun.jeong@samsung.com>
Wed, 16 Aug 2023 08:17:15 +0000 (17:17 +0900)
committerANZ1217 <chihun.jeong@samsung.com>
Wed, 16 Aug 2023 08:17:15 +0000 (17:17 +0900)
Change-Id: I629a029f987242addf7bf69ec5b3a4af34f0226d

libaurum/src/Impl/Accessibility/AtspiAccessibleWatcher.cc
libaurum/src/Impl/MockDeviceImpl.cc
libaurum/src/Impl/TizenDeviceImpl.cc

index 8684f55..81cdb20 100644 (file)
@@ -575,7 +575,7 @@ void AtspiAccessibleWatcher::setXMLsync(bool sync)
         mAppXMLLoadedCount = 0;
     } else {
         auto apps = getApplications();
-        for (auto app : apps)
+        for (auto &app : apps)
         {
             app->getAccessibleNode()->updateName();
             mAppCount++;
index 6c72a24..db933f4 100644 (file)
@@ -272,7 +272,7 @@ std::vector<std::shared_ptr<AccessibleNode>> MockDeviceImpl::getWindowRoot() con
 
     auto apps = AccessibleWatcher::getInstance()->getApplications();
 
-    for (auto app : apps)
+    for (auto &app : apps)
     {
         auto wins = app->getWindows();
         std::transform(wins.begin(), wins.end(), std::back_inserter(ret),
index bd29ad2..c99b130 100644 (file)
@@ -448,7 +448,7 @@ std::vector<std::shared_ptr<AccessibleNode>> TizenDeviceImpl::getWindowRoot() co
     std::unordered_map<int, std::shared_ptr<AccessibleApplication>> pidToAppNode{};
 
     auto apps = AccessibleWatcher::getInstance()->getApplications();
-    for (auto app : apps)
+    for (auto &app : apps)
     {
         app->getAccessibleNode()->updateName();
         app->getAccessibleNode()->updatePid();
@@ -457,7 +457,7 @@ std::vector<std::shared_ptr<AccessibleNode>> TizenDeviceImpl::getWindowRoot() co
         pidToAppNode[app->getAccessibleNode()->getPid()] = app;
     }
 
-    for (auto tWin : mTizenWindows)
+    for (auto &tWin : mTizenWindows)
     {
         LOGI("Visible win (%d) (%d %d %d %d) (%s)", tWin->getPid(), tWin->getWindowGeometry().mTopLeft.x, tWin->getWindowGeometry().mTopLeft.y, tWin->getWindowGeometry().width(),
             tWin->getWindowGeometry().height(), tWin->getName().c_str());