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

Message ID 44FC8901.908@gmx.de
State New
Headers

Commit Message

Udo Richter Sept. 4, 2006, 8:13 p.m. UTC
  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
  

Comments

Klaus Schmidinger Sept. 4, 2006, 8:25 p.m. UTC | #1
Udo Richter wrote:
> 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. ;)

That'll teach me not to write code when I'm on my way out to the
"Biergarten"... ;-)

Thanks.

Klaus
  
martin Sept. 4, 2006, 8:44 p.m. UTC | #2
Okay, vdr-1.4.2.1-timerassign-2.diff did work :-) Thanks Udo and Klaus for
coding!

So, I'm happy now and can relax on my balcony with a Weißbier :-)

Greetz from Munich,
Martin

-----Ursprüngliche Nachricht-----
Von: vdr-bounces@linuxtv.org [mailto:vdr-bounces@linuxtv.org] Im Auftrag von
Klaus Schmidinger
Gesendet: Montag, 4. September 2006 22:25
An: vdr@linuxtv.org
Betreff: Re: AW: [vdr] *** glibc detected *** double free or corruption
1.4.2-1 Patch

Udo Richter wrote:
> 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. ;)

That'll teach me not to write code when I'm on my way out to the
"Biergarten"... ;-)

Thanks.

Klaus
  
Udo Richter Sept. 4, 2006, 9:30 p.m. UTC | #3
Klaus Schmidinger wrote:
> That'll teach me not to write code when I'm on my way out to the
> "Biergarten"... ;-)

Next time, do it afterwards. Afterwards, code is much more 'fluently'. ;)

Cheers,

Udo
  

Patch

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;