LibCecSharp: fixed 14 char long OSD name (wasn't \0 terminated)
[deb_libcec.git] / src / LibCecSharp / LibCecSharp.cpp
index ecb9bea9223f0f74abefa161f3f7f08818df7078..0bae3eaca39e9d820f49b605968b6e39d78fa580 100644 (file)
@@ -377,7 +377,7 @@ namespace CecSharp
 
       for (uint8_t iPtr = 0; iPtr < 16; iPtr++)
         if (activeDevices[iPtr])
-          retVal->Addresses[iDevices++] = (CecLogicalAddress)iPtr;
+          retVal->Set((CecLogicalAddress)iPtr);
 
       return retVal;
     }
@@ -474,7 +474,11 @@ namespace CecSharp
     String ^ GetDeviceOSDName(CecLogicalAddress logicalAddress)
     {
       cec_osd_name osd = m_libCec->GetDeviceOSDName((cec_logical_address) logicalAddress);
-      return gcnew String(osd.name);
+      // we need to terminate with \0, and we only got 14 chars in osd.name
+      char strOsdName[15];
+      memset(strOsdName, 0, sizeof(strOsdName));
+      memcpy(strOsdName, osd.name, sizeof(osd.name));
+      return gcnew String(strOsdName);
     }
 
     /// <summary>