AW: [vdr] *** glibc detected *** double free or corruption 1.4.2-1 Patch

Udo Richter udo_richter at gmx.de
Mon Sep 4 22:13:53 CEST 2006


martin wrote:
> just to let you know: the patch you attached here, did not solve the
> problem! My VDR crashed again.

Just a few minutes too late...

The patch had another bug that re-introduced the original problem once 
again. The new copy constructor did not initialize the aux pointer, and 
the assign operator consequently free'd its uninitialized value - and 
with some luck, thats a valid pointer.

The attached patch does the missing initialization. Hopefully, thats the 
last bug. ;)

Cheers,

Udo

-------------- next part --------------
diff -Naur vdr-1.4.2-1-orig/timers.c vdr-1.4.2-1/timers.c
--- vdr-1.4.2-1-orig/timers.c	2006-09-04 22:03:05.553657432 +0200
+++ vdr-1.4.2-1/timers.c	2006-09-04 22:07:03.904017384 +0200
@@ -83,6 +83,16 @@
   event = NULL; // let SetEvent() be called to get a log message
 }
 
+cTimer::cTimer(const cTimer &Timer)
+{
+  // initialize at least the pointers
+  channel = NULL;
+  aux = NULL;
+  event = NULL;
+  // assign operator does the rest
+  *this = Timer;
+}
+
 cTimer::~cTimer()
 {
   free(aux);
@@ -90,24 +100,26 @@
 
 cTimer& cTimer::operator= (const cTimer &Timer)
 {
-  startTime    = Timer.startTime;
-  stopTime     = Timer.stopTime;
-  lastSetEvent = 0;
-  recording    = Timer.recording;
-  pending      = Timer.pending;
-  inVpsMargin  = Timer.inVpsMargin;
-  flags        = Timer.flags;
-  channel      = Timer.channel;
-  day          = Timer.day;
-  weekdays     = Timer.weekdays;
-  start        = Timer.start;
-  stop         = Timer.stop;
-  priority     = Timer.priority;
-  lifetime     = Timer.lifetime;
-  strncpy(file, Timer.file, sizeof(file));
-  free(aux);
-  aux = Timer.aux ? strdup(Timer.aux) : NULL;
-  event = NULL;
+  if (&Timer != this) {
+     startTime    = Timer.startTime;
+     stopTime     = Timer.stopTime;
+     lastSetEvent = 0;
+     recording    = Timer.recording;
+     pending      = Timer.pending;
+     inVpsMargin  = Timer.inVpsMargin;
+     flags        = Timer.flags;
+     channel      = Timer.channel;
+     day          = Timer.day;
+     weekdays     = Timer.weekdays;
+     start        = Timer.start;
+     stop         = Timer.stop;
+     priority     = Timer.priority;
+     lifetime     = Timer.lifetime;
+     strncpy(file, Timer.file, sizeof(file));
+     free(aux);
+     aux = Timer.aux ? strdup(Timer.aux) : NULL;
+     event = NULL;
+     }
   return *this;
 }
 
diff -Naur vdr-1.4.2-1-orig/timers.h vdr-1.4.2-1/timers.h
--- vdr-1.4.2-1-orig/timers.h	2006-04-08 14:41:44.000000000 +0200
+++ vdr-1.4.2-1/timers.h	2006-09-04 22:05:16.041820216 +0200
@@ -44,6 +44,7 @@
 public:
   cTimer(bool Instant = false, bool Pause = false, cChannel *Channel = NULL);
   cTimer(const cEvent *Event);
+  cTimer(const cTimer &Timer);
   virtual ~cTimer();
   cTimer& operator= (const cTimer &Timer);
   virtual int Compare(const cListObject &ListObject) const;


More information about the vdr mailing list