]> git.vomp.tv Git - vompclient.git/commitdiff
Fix segfault when using subtitles
authorChris Tallon <chris@vomp.tv>
Thu, 30 Mar 2017 17:20:45 +0000 (18:20 +0100)
committerChris Tallon <chris@vomp.tv>
Thu, 30 Mar 2017 17:20:45 +0000 (18:20 +0100)
The segfault occurs in pthread_exit which points at memory corruption...

The problem:
Play live/recording, switch subtitles on. No subtitle packets arrive from
the demuxer (a channel without subtitles or just a part of a programme with
no dialogue).
Navigate or stop (anything to switch from playing to stopped).
cTimeMs returns a small positive integer because it has never been
initialised with anything other than 0.
This value is negated inside an unsigned creating a very large number
for "wakeup" which causes targetTime to overflow to
a negative number. This is supplied to pthread_cond_timedwait which
causes the spin.
Something about this situation causes pthread_exit to segfault
when DVBSubtitles->threadStop() is called.

Also fixed missing else brackets in cTimeMs constructor.

dvbsubtitles.cc
dvbsubtitles.h

index 316e4035088c172df8f124c12f167ba86b101ae4..5351b6f5706aa5c84c912649806bf3183feb694a 100644 (file)
 
 cTimeMs::cTimeMs(int Ms)
 {
+  initted = false;
+
   if (Ms >= 0)
      Set(Ms);
   else
+  {
      begin = 0;
      isFirstCheck = false;
+  }
 }
 
 uint64_t cTimeMs::Now(void)
@@ -59,6 +63,8 @@ void cTimeMs::Set(int Ms)
 {
   isFirstCheck = true; // Timer set, the first check can be done once
   begin = Now() + Ms;
+
+  if (Ms) initted = true;
 }
 
 bool cTimeMs::TimedOut(void)
@@ -74,6 +80,7 @@ bool cTimeMs::TimedOut(void)
 
 uint64_t cTimeMs::Elapsed(void)
 {
+  if (!initted) return 0;
   return Now() - begin;
 }
 
index 701bf9e64c0665e64e80c19b30b75cbedc875aaa..d268169a41c8b21e595d0ad3c72a24de2771f955 100644 (file)
@@ -48,6 +48,7 @@ class cTimeMs {
     void Set(int Ms = 0);
     bool TimedOut(void);
     uint64_t Elapsed(void);
+    bool initted;
 };
 
 class OSDReceiver;