aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Simon Moeller <jsmoeller@linuxfoundation.org>2019-02-18 10:39:34 +0000
committerGerrit Code Review <gerrit@automotivelinux.org>2019-02-18 10:39:34 +0000
commitec58658f638a8d433f75d64807c0af4db6987e5a (patch)
treeadaa96f23b7a872dd4bbd2b08e83d8eb11ccd32e
parente9e1d37d422da00f6b4c53fce9dccfd0ca7138db (diff)
parent41060cd08cbc3b42ed59b9e117e8769f43295316 (diff)
Merge "Fix memory corruption issue when unregistering surfaces" into flounderflounder_6.0.5flounder/6.0.56.0.5flounder
-rw-r--r--src/runxdg.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/runxdg.cpp b/src/runxdg.cpp
index 356e24f..6b8018e 100644
--- a/src/runxdg.cpp
+++ b/src/runxdg.cpp
@@ -28,6 +28,7 @@
#include <sys/time.h>
#include <sys/wait.h>
+#include <algorithm>
#include <cstdio>
#include "cpptoml/cpptoml.h"
@@ -518,14 +519,10 @@ void POSIXLauncher::register_surfpid (pid_t surf_pid)
void POSIXLauncher::unregister_surfpid (pid_t surf_pid)
{
- auto itr = m_pid_v.begin();
- while (itr != m_pid_v.end()) {
- if (*itr == surf_pid) {
- m_pid_v.erase(itr++);
- } else {
- ++itr;
- }
- }
+ auto beg = m_pid_v.begin();
+ auto end = m_pid_v.end();
+ m_pid_v.erase(std::remove(beg, end, surf_pid), end);
+ AGL_DEBUG("Unregistered surface (id=%d sz=%u)", surf_pid, m_pid_v.size());
}
pid_t POSIXLauncher::find_surfpid_by_rid (pid_t rid)