From 6404cc37c7ea5f968455641739a06857d424230d Mon Sep 17 00:00:00 2001
From: Vincent Lucas <chenzo@jitsi.org>
Date: Fri, 14 Dec 2012 10:08:45 +0000
Subject: [PATCH] Corrects invalid read access from the MacOsX/Windows libjitsi
 coreaudio library when creating or receiving a call without any microphone
 connected.

---
 .../neomedia/maccoreaudio/CoreAudioVolumeControl.java  | 10 ++++++++++
 .../neomedia/wincoreaudio/CoreAudioVolumeControl.java  | 10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/src/org/jitsi/impl/neomedia/maccoreaudio/CoreAudioVolumeControl.java b/src/org/jitsi/impl/neomedia/maccoreaudio/CoreAudioVolumeControl.java
index 87365350..d8ed0896 100644
--- a/src/org/jitsi/impl/neomedia/maccoreaudio/CoreAudioVolumeControl.java
+++ b/src/org/jitsi/impl/neomedia/maccoreaudio/CoreAudioVolumeControl.java
@@ -51,6 +51,11 @@ public CoreAudioVolumeControl(
      */
     protected int setInputDeviceVolume(String deviceUID, float volume)
     {
+        if(deviceUID == null)
+        {
+            return -1;
+        }
+
         // Changes the input volume of the capture device.
         if(CoreAudioDevice.setInputDeviceVolume(deviceUID, volume) != 0)
         {
@@ -71,6 +76,11 @@ protected int setInputDeviceVolume(String deviceUID, float volume)
      */
     protected float getInputDeviceVolume(String deviceUID)
     {
+        if(deviceUID == null)
+        {
+            return -1;
+        }
+
         float volume = CoreAudioDevice.getInputDeviceVolume(deviceUID);
 
         if(logger.isDebugEnabled() && (volume != 0))
diff --git a/src/org/jitsi/impl/neomedia/wincoreaudio/CoreAudioVolumeControl.java b/src/org/jitsi/impl/neomedia/wincoreaudio/CoreAudioVolumeControl.java
index e6052abd..d64acd9f 100644
--- a/src/org/jitsi/impl/neomedia/wincoreaudio/CoreAudioVolumeControl.java
+++ b/src/org/jitsi/impl/neomedia/wincoreaudio/CoreAudioVolumeControl.java
@@ -51,6 +51,11 @@ public CoreAudioVolumeControl(
      */
     protected int setInputDeviceVolume(String deviceUID, float volume)
     {
+        if(deviceUID == null)
+        {
+            return -1;
+        }
+
         if(CoreAudioDevice.initDevices() == -1)
         {
             CoreAudioDevice.freeDevices();
@@ -83,6 +88,11 @@ protected float getInputDeviceVolume(String deviceUID)
     {
         float volume;
 
+        if(deviceUID == null)
+        {
+            return -1;
+        }
+
         if(CoreAudioDevice.initDevices() == -1)
         {
             CoreAudioDevice.freeDevices();
-- 
GitLab