decklink: Don't crash when getting hw serial number doesn't return OK
authorVivia Nikolaidou <vivia@ahiru.eu>
Wed, 8 Nov 2017 22:16:21 +0000 (00:16 +0200)
committerVivia Nikolaidou <vivia@ahiru.eu>
Wed, 8 Nov 2017 22:19:42 +0000 (00:19 +0200)
If the return value isn't OK, it means we might be getting data that
points to an invalid memory address. That shouldn't make us crash.

sys/decklink/gstdecklink.cpp

index 58af0c6074accd7838441d38e9c7f2d86355cde6..85498c9b13262bd34c2e9ebe16835809b67fb83d 100644 (file)
@@ -1239,11 +1239,13 @@ init_devices (gpointer data)
           devices[i].input.
           config->GetString (bmdDeckLinkConfigDeviceInformationSerialNumber,
           (COMSTR_T *) & serial_number);
-      CONVERT_COM_STRING (serial_number);
-      devices[i].output.hw_serial_number = g_strdup (serial_number);
-      devices[i].input.hw_serial_number = g_strdup (serial_number);
-      GST_DEBUG ("device %d has serial number %s", i, serial_number);
-      FREE_COM_STRING (serial_number);
+      if (ret == S_OK) {
+        CONVERT_COM_STRING (serial_number);
+        devices[i].output.hw_serial_number = g_strdup (serial_number);
+        devices[i].input.hw_serial_number = g_strdup (serial_number);
+        GST_DEBUG ("device %d has serial number %s", i, serial_number);
+        FREE_COM_STRING (serial_number);
+      }
     }
 
     ret = decklink->QueryInterface (IID_IDeckLinkAttributes,