rotor plugin puzzling question

Message ID df3234b05734d0debc0ca20e63f6b9d9@imap.embl.de
State New
Headers

Commit Message

martinez@embl.de Nov. 11, 2009, 8:40 p.m. UTC
  Is it just me or the newly released rotor plugin for vdr 1.7.9 needs the
following patch to the plugin itself in order to run (although it compiles
fine without it)
If the author reads these lines I would love to know why...

       while (c = strchr(c, '['))
       {
         char *e = strchr(++c, ']');
@@ -131,7 +132,7 @@
           break;
         }
       }
-      free(c);
+      free(commandstring);
     }
     cRotorPos *p = RotorPositions.GetfromSource(source->Code());
     if (p==RotorPositions.First())
  

Comments

Chris Moore Nov. 12, 2009, 5:31 a.m. UTC | #1
Hello,

ACK: this was clearly a bug ;-)

martinez@embl.de a écrit :
> Is it just me or the newly released rotor plugin for vdr 1.7.9 needs the
> following patch to the plugin itself in order to run (although it compiles
> fine without it)
> If the author reads these lines I would love to know why...
>
> --- rotor.c.old	2006-06-14 23:44:27.000000000 +0200
> +++ rotor.c	2006-06-14 23:46:43.000000000 +0200
> @@ -96,7 +96,8 @@
>        continue;
>      if ((diseqc=Diseqcs.Get(source->Code(),12000,'h')) ||
> (diseqc=Diseqcs.Get(source->Code(),12000,'v')) ||
> (diseqc=Diseqcs.Get(source->Code(),12000,'l')) ||
> (diseqc=Diseqcs.Get(source->Code(),12000,'r'))) 
>      {
> -      char *c=strdup(diseqc->Commands());
> +      char *commandstring=strdup(diseqc->Commands());
> +      char *c=commandstring;      
>        while (c = strchr(c, '['))
>        {
>          char *e = strchr(++c, ']');
> @@ -131,7 +132,7 @@
>            break;
>          }
>        }
> -      free(c);
> +      free(commandstring);
>   

I am not the author (nor even a user) but you are absolutely right.
You must free the pointer as returned by strdup; not one that you have 
modified or incremented :(
So you need to keep a virgin copy of the pointer as you have done.

Cheers,
Chris
  
Goga777 Nov. 12, 2009, 2:56 p.m. UTC | #2
I couldn't apply a patch 


/usr/src/vdr/PLUGINS/src/rotor-0.1.5# cat patch1 | patch -p0 --dry-run
patching file rotor.c
patch: **** malformed patch at line 6: (diseqc=Diseqcs.Get(source->Code(),12000,'v')) ||


any clue ?

> Is it just me or the newly released rotor plugin for vdr 1.7.9 needs the
> following patch to the plugin itself in order to run (although it compiles
> fine without it)
> If the author reads these lines I would love to know why...
> 
> --- rotor.c.old	2006-06-14 23:44:27.000000000 +0200
> +++ rotor.c	2006-06-14 23:46:43.000000000 +0200
> @@ -96,7 +96,8 @@
>        continue;
>      if ((diseqc=Diseqcs.Get(source->Code(),12000,'h')) ||
> (diseqc=Diseqcs.Get(source->Code(),12000,'v')) ||
> (diseqc=Diseqcs.Get(source->Code(),12000,'l')) ||
> (diseqc=Diseqcs.Get(source->Code(),12000,'r'))) 
>      {
> -      char *c=strdup(diseqc->Commands());
> +      char *commandstring=strdup(diseqc->Commands());
> +      char *c=commandstring;      
>        while (c = strchr(c, '['))
>        {
>          char *e = strchr(++c, ']');
> @@ -131,7 +132,7 @@
>            break;
>          }
>        }
> -      free(c);
> +      free(commandstring);
>      }
>      cRotorPos *p = RotorPositions.GetfromSource(source->Code());
>      if (p==RotorPositions.First())
  
Arthur Konovalov Nov. 12, 2009, 3:17 p.m. UTC | #3
Goga777 wrote:
> I couldn't apply a patch 
> 
> 
> /usr/src/vdr/PLUGINS/src/rotor-0.1.5# cat patch1 | patch -p0 --dry-run
> patching file rotor.c
> patch: **** malformed patch at line 6: (diseqc=Diseqcs.Get(source->Code(),12000,'v')) ||

>>      if ((diseqc=Diseqcs.Get(source->Code(),12000,'h')) ||
>> (diseqc=Diseqcs.Get(source->Code(),12000,'v')) ||
>> (diseqc=Diseqcs.Get(source->Code(),12000,'l')) ||
>> (diseqc=Diseqcs.Get(source->Code(),12000,'r'))) 

There only one line and it wrapped to 4 parts. You should join these parts to 
one line.
  

Patch

--- rotor.c.old	2006-06-14 23:44:27.000000000 +0200
+++ rotor.c	2006-06-14 23:46:43.000000000 +0200
@@ -96,7 +96,8 @@ 
       continue;
     if ((diseqc=Diseqcs.Get(source->Code(),12000,'h')) ||
(diseqc=Diseqcs.Get(source->Code(),12000,'v')) ||
(diseqc=Diseqcs.Get(source->Code(),12000,'l')) ||
(diseqc=Diseqcs.Get(source->Code(),12000,'r'))) 
     {
-      char *c=strdup(diseqc->Commands());
+      char *commandstring=strdup(diseqc->Commands());
+      char *c=commandstring;