]> git.vomp.tv Git - vompserver.git/commitdiff
Crash fix when no info.vdr
authorChris Tallon <chris@vomp.tv>
Sun, 8 Oct 2006 18:49:21 +0000 (18:49 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 8 Oct 2006 18:49:21 +0000 (18:49 +0000)
mvpclient.c

index 184ed304242d74340c8d77b817a9c855ae122c6c..87a8cfb552524f38470ba6dc632058fe797129d7 100644 (file)
@@ -1653,57 +1653,66 @@ int MVPClient::processGetRecInfo(UCHAR* data, int length)
 #else
   const cComponents* components = Info->Components();
 
-  *(ULONG*)&sendBuffer[pos] = htonl(components->NumComponents());    pos += 4;
+  log->log("Client", Log::DEBUG, "GRI: D1: %p", components);
 
-  tComponent* component;
-  for (int i = 0; i < components->NumComponents(); i++)
+  if (!components)
   {
-    component = components->Component(i);
-
-    // memory insanity...
-    ULONG extraNeeded = 2 + (component->language ? strlen(component->language) : 0)
-                          + (component->description ? strlen(component->description) : 0) + 2;
+    *(ULONG*)&sendBuffer[pos] = htonl(0);    pos += 4;
+  }
+  else
+  {
+    *(ULONG*)&sendBuffer[pos] = htonl(components->NumComponents());    pos += 4;
 
-    if ((sendBufferSize - pos) < extraNeeded)
+    tComponent* component;
+    for (int i = 0; i < components->NumComponents(); i++)
     {
-      UCHAR* newBuffer = (UCHAR*)realloc(sendBuffer, sendBufferSize + extraNeeded + 10000);
-      if (newBuffer)
+      component = components->Component(i);
+
+      // memory insanity...
+      ULONG extraNeeded = 2 + (component->language ? strlen(component->language) : 0)
+                            + (component->description ? strlen(component->description) : 0) + 2;
+
+      if ((sendBufferSize - pos) < extraNeeded)
       {
-        sendBuffer = newBuffer;
-        sendBufferSize += extraNeeded + 10000;
+        UCHAR* newBuffer = (UCHAR*)realloc(sendBuffer, sendBufferSize + extraNeeded + 10000);
+        if (newBuffer)
+        {
+          sendBuffer = newBuffer;
+          sendBufferSize += extraNeeded + 10000;
+        }
+        else
+        {
+          free(sendBuffer);
+          sendULONG(0);
+          return 1;
+        }
+      }
+
+      log->log("Client", Log::DEBUG, "GRI: C: %i %u %u %s %s", i, component->stream, component->type, component->language, component->description);
+      sendBuffer[pos] = component->stream;  pos += 1;
+      sendBuffer[pos] = component->type;    pos += 1;
+      if (component->language)
+      {
+        strcpy((char*)&sendBuffer[pos], component->language);
+        pos += strlen(component->language) + 1;
       }
       else
       {
-        free(sendBuffer);
-        sendULONG(0);
-        return 1;
+        strcpy((char*)&sendBuffer[pos], "");
+        pos += 1;
+      }
+      if (component->description)
+      {
+        strcpy((char*)&sendBuffer[pos], component->description);
+        pos += strlen(component->description) + 1;
+      }
+      else
+      {
+        strcpy((char*)&sendBuffer[pos], "");
+        pos += 1;
       }
-    }
 
-    log->log("Client", Log::DEBUG, "GRI: C: %i %u %u %s %s", i, component->stream, component->type, component->language, component->description);
-    sendBuffer[pos] = component->stream;  pos += 1;
-    sendBuffer[pos] = component->type;    pos += 1;
-    if (component->language)
-    {
-      strcpy((char*)&sendBuffer[pos], component->language);
-      pos += strlen(component->language) + 1;
     }
-    else
-    {
-      strcpy((char*)&sendBuffer[pos], "");
-      pos += 1;
-    }
-    if (component->description)
-    {
-      strcpy((char*)&sendBuffer[pos], component->description);
-      pos += strlen(component->description) + 1;
-    }
-    else
-    {
-      strcpy((char*)&sendBuffer[pos], "");
-      pos += 1;
-    }
-
   }
 
 #endif