[VoiceControl/VoiceControlWidget] Fix invalid null checking (#96)
authorstomHwang <35016426+stomHwang@users.noreply.github.com>
Mon, 29 Jan 2018 05:41:04 +0000 (14:41 +0900)
committerGitHub <noreply@github.com>
Mon, 29 Jan 2018 05:41:04 +0000 (14:41 +0900)
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
internal/src/Tizen.Uix.VoiceControlWidget/Tizen.Uix.VoiceControlWidget/VoiceControlWidget.cs
src/Tizen.Uix.VoiceControl/Tizen.Uix.VoiceControl/VoiceControlClient.cs

index 75d7c4c..58a235e 100755 (executable)
@@ -677,7 +677,7 @@ namespace Tizen.Uix.VoiceControlWidget
                 _resultDelegate = (ResultEvent evt, IntPtr cmdList, IntPtr result, IntPtr userData) =>
                 {
                     Log.Info(LogTag, "Recognition Result Event Triggered");
-                    if ((cmdList != null) && (result != null))
+                    if (IntPtr.Zero != cmdList && IntPtr.Zero != result)
                     {
                         RecognitionResult args = new RecognitionResult(evt, cmdList, result);
                         _recognitionResult?.Invoke(null, args);
index b613397..952ef9d 100755 (executable)
@@ -195,7 +195,7 @@ namespace Tizen.Uix.VoiceControl
     };
 
     /// <summary>
-    /// A main function of the voice control API registers the command and gets a notification for the recognition result. 
+    /// A main function of the voice control API registers the command and gets a notification for the recognition result.
     /// Applications can add their own commands and provide results when their command is recognized by the user voice input.
     /// </summary>
     /// <since_tizen> 3 </since_tizen>
@@ -723,7 +723,14 @@ namespace Tizen.Uix.VoiceControl
             s_recognitionResult = null;
             s_resultCb = (ResultEvent evt, IntPtr cmdList, IntPtr result, IntPtr userData) =>
             {
-                s_recognitionResult = new RecognitionResult(evt, cmdList, result);
+                if (IntPtr.Zero != cmdList && IntPtr.Zero != result)
+                {
+                    s_recognitionResult = new RecognitionResult(evt, cmdList, result);
+                }
+                else
+                {
+                    Log.Info(LogTag, "cmdList or result is null");
+                }
             };
             ErrorCode error = VcGetResult(s_resultCb, IntPtr.Zero);
             if (error != ErrorCode.None)
@@ -749,9 +756,9 @@ namespace Tizen.Uix.VoiceControl
                 s_resultDelegate = (ResultEvent evt, IntPtr cmdList, IntPtr result, IntPtr userData) =>
                 {
                     Log.Info(LogTag, "Recognition Result Event Triggered");
-                    if ((cmdList != null) && (result != null))
+                    if (IntPtr.Zero != cmdList && IntPtr.Zero != result)
                     {
-                        RecognitionResultEventArgs args = new RecognitionResultEventArgs(new RecognitionResult( evt, cmdList, result));
+                        RecognitionResultEventArgs args = new RecognitionResultEventArgs(new RecognitionResult(evt, cmdList, result));
                         _recognitionResult?.Invoke(null, args);
                     }
                     else