vdr-1.3.32 segfault when reading summary.vdr

Message ID 200509152227.54151.skiller2k1@gmx.net
State New
Headers

Commit Message

skiller2k1 Sept. 15, 2005, 8:27 p.m. UTC
  Am Donnerstag 15 September 2005 19:32 schrieb Achim Tuffentsammer:
> Hi list,
>
> I have a summary.vdr file from the old days
> which crashes vdr 1.3.32 when trying to read it.
>
> Attached is the summary.vdr file and a small
> patch to recording.c which prevents vdr from
> crashing.
>
> Achim

Hi Achim, i patched it another way ;)
See attached file.

Michi
  

Patch

--- vdr-1.3.32/recording.c	2005-09-15 21:24:30.000000000 +0200
+++ vdr-1.3.32.patch/recording.c	2005-09-15 21:13:21.000000000 +0200
@@ -477,7 +477,7 @@ 
         FILE *f = fopen(SummaryFileName, "r");
         if (f) {
            int line = 0;
-           char *data[3] = { NULL };
+           char *data[3] = { NULL, NULL, NULL };
            cReadLine ReadLine;
            char *s;
            while ((s = ReadLine.Read(f)) != NULL) {
@@ -501,19 +501,21 @@ 
               data[1] = NULL;
               }
            else if (line == 2) {
-              // if line 1 is too long, it can't be the short text,
-              // so assume the short text is missing and concatenate
-              // line 1 and line 2 to be the long text:
-              int len = strlen(data[1]);
-              if (len > 80) { 
-                 data[1] = (char *)realloc(data[1], len + 1 + strlen(data[2]) + 1);
-                 strcat(data[1], "\n");
-                 strcat(data[1], data[2]);
-                 free(data[2]);
-                 data[2] = data[1];
-                 data[1] = NULL;
+	      if (data[1]) {
+		 // if line 1 is too long, it can't be the short text,
+		 // so assume the short text is missing and concatenate
+		 // line 1 and line 2 to be the long text:
+		 int len = strlen(data[1]);
+		 if (len > 80) { 
+		    data[1] = (char *)realloc(data[1], len + 1 + strlen(data[2]) + 1);
+		    strcat(data[1], "\n");
+		    strcat(data[1], data[2]);
+		    free(data[2]);
+		    data[2] = data[1];
+		    data[1] = NULL;
+                    }
                  }
-              }
+	      }
            info->SetData(data[0], data[1], data[2]);
            for (int i = 0; i < 3; i ++)
                free(data[i]);