Fix memory double freed issue 55/145955/1 tizen
authorSuyeon Hwang <stom.hwang@samsung.com>
Thu, 24 Aug 2017 08:52:20 +0000 (17:52 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Thu, 24 Aug 2017 08:52:20 +0000 (17:52 +0900)
Change-Id: I425dcbfcb4be9a3022b5f76d7ebf3d1ff8f6242d
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
Tizen.Uix.VoiceControl/Tizen.Uix.VoiceControl/VoiceCommandList.cs

index 3b9d4ca..8573076 100755 (executable)
@@ -141,6 +141,7 @@ namespace Tizen.Uix.VoiceControl
                     return null;
                 }
 
+                current._ownership = false;
                 return _list[_index];
             }
         }
@@ -223,12 +224,12 @@ namespace Tizen.Uix.VoiceControl
         /// <exception cref="NotSupportedException">This exception can be due to not supported.</exception>
         public IEnumerable<VoiceCommand> GetAllCommands()
         {
-            List<VoiceCommand> commandList = new List<VoiceCommand>();
             _callback = (IntPtr vcCommand, IntPtr userData) =>
             {
-                SafeCommandHandle handle = new SafeCommandHandle(vcCommand);
-                handle._ownership = false;
-                commandList.Add(new VoiceCommand(handle));
+                if (IntPtr.Zero == vcCommand) {
+                    Log.Error(LogTag, "Invalid command pointer");
+                    return false;
+                }
                 return true;
             };
             ErrorCode error = VcCmdListForeachCommands(_handle, _callback, IntPtr.Zero);