Bug 1260745 - Null-check the `friendly_name` field in a `cubeb_device`. r?jesup draft
authorPaul Adenot <paul@paul.cx>
Wed, 30 Mar 2016 16:47:02 +0200
changeset 345859 6a1f2cf57db5cc4b76c0113c9308d5c37d328cf3
parent 345720 494289c72ba3997183e7b5beaca3e0447ecaf96d
child 345924 ad3594cc18e89ac2dab664b3b5a3996bf2589e99
child 345927 839890bd984e49b414dbf702994d211da5b5b776
push id14187
push userpaul@paul.cx
push dateWed, 30 Mar 2016 14:47:37 +0000
reviewersjesup
bugs1260745
milestone48.0a1
Bug 1260745 - Null-check the `friendly_name` field in a `cubeb_device`. r?jesup They can be null, according to the cubeb API. MozReview-Commit-ID: FOKG2kTy9NX
dom/media/webrtc/MediaEngineWebRTC.cpp
--- a/dom/media/webrtc/MediaEngineWebRTC.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTC.cpp
@@ -73,16 +73,17 @@ void AudioInputCubeb::UpdateDeviceList()
   // stashed indexes.
   // For some reason the "fake" device for automation is marked as DISABLED,
   // so white-list it.
   for (uint32_t i = 0; i < devices->count; i++) {
     if (devices->device[i]->type == CUBEB_DEVICE_TYPE_INPUT && // paranoia
         (devices->device[i]->state == CUBEB_DEVICE_STATE_ENABLED ||
          devices->device[i]->state == CUBEB_DEVICE_STATE_UNPLUGGED ||
          (devices->device[i]->state == CUBEB_DEVICE_STATE_DISABLED &&
+          devices->device[i]->friendly_name &&
           strcmp(devices->device[i]->friendly_name, "Sine source at 440 Hz") == 0)))
     {
       auto j = mDeviceNames->IndexOf(devices->device[i]->device_id);
       if (j != nsTArray<nsCString>::NoIndex) {
         // match! update the mapping
         (*mDeviceIndexes)[j] = i;
       } else {
         // new device, add to the array