From d329d7fe60823b9daa353fc19e77a42cf08fdc6c Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Tue, 12 Jan 2016 23:53:06 +0100 Subject: [PATCH] sectionsd.cpp: Fix error 'heap-use-after-free' reported by AddressSanitizer Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/e2f282ccc97744f1436081a2175bacded5b8f788 Author: Michael Liebmann Date: 2016-01-12 (Tue, 12 Jan 2016) --- src/eitd/eitd.h | 2 ++ src/eitd/sectionsd.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/eitd/eitd.h b/src/eitd/eitd.h index a082b401f..8d2c579c9 100644 --- a/src/eitd/eitd.h +++ b/src/eitd/eitd.h @@ -114,6 +114,8 @@ class CSectionThread : public OpenThreads::Thread, public DMX int skipTime; bool sendToSleepNow; + std::string threadName; + /* should thread wait for time set before process loop */ bool wait_for_time; /* time in seconds to sleep when requested, wait forever if 0 */ diff --git a/src/eitd/sectionsd.cpp b/src/eitd/sectionsd.cpp index 335be390d..6daebdfdf 100644 --- a/src/eitd/sectionsd.cpp +++ b/src/eitd/sectionsd.cpp @@ -1432,8 +1432,8 @@ void CTimeThread::run() time_t dvb_time = 0; bool retry = false; /* if time seems fishy, set to true and try again */ xprintf("%s::run:: starting, pid %d (%lu)\n", name.c_str(), getpid(), pthread_self()); - const char *tn = ("sd:" + name).c_str(); - set_threadname(tn); + threadName = "sd:" + name; + set_threadname(threadName.c_str()); addFilters(); DMX::start(); @@ -1568,8 +1568,8 @@ int CSectionThread::Sleep() void CSectionThread::run() { xprintf("%s::run:: starting, pid %d (%lu)\n", name.c_str(), getpid(), pthread_self()); - const char *tn = ("sd:" + name).c_str(); - set_threadname(tn); + threadName = "sd:" + name; + set_threadname(threadName.c_str()); if (sections_debug) dump_sched_info(name);