Fix some SVACE issues.
authorzhouhao02 <haozhou.zhou@samsung.com>
Wed, 11 Oct 2023 06:05:52 +0000 (14:05 +0800)
committerEunki Hong <h.pichulia@gmail.com>
Tue, 31 Oct 2023 14:07:28 +0000 (23:07 +0900)
src/Tizen.NUI.Physics2D/src/internal/chipmunk/cpSpaceDebugDrawOptions.cs
src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs
src/Tizen.NUI/src/public/BaseComponents/DirectRenderingGLView.cs

index d787f6e..7b9afef 100644 (file)
@@ -104,15 +104,13 @@ namespace Tizen.NUI.Physics2D.Chipmunk
         private IntPtr ToPointer()
         {
             IntPtr drawOptionsPtr = NativeInterop.AllocStructure<cpSpaceDebugDrawOptions>();
-            try
+            if (Marshal.SizeOf(typeof(cpSpaceDebugDrawOptions)) == 0)
             {
-                Marshal.StructureToPtr<cpSpaceDebugDrawOptions>(this, drawOptionsPtr, false);
+                throw new ArgumentNullException("The size of type cpSpaceDebugDrawOptions should not be 0.");
             }
-            catch (Exception exception)
-            {
-                Tizen.Log.Fatal("NUI", "[Error] got exception during Marshal.StructureToPtr, this should not occur, message : " + exception.Message);
-            }
-      
+
+            Marshal.StructureToPtr<cpSpaceDebugDrawOptions>(this, drawOptionsPtr, false);
+
             return drawOptionsPtr;
         }
 
index 266e0b4..a7b98c6 100755 (executable)
@@ -202,9 +202,9 @@ namespace Tizen.NUI.Xaml
 
                 Values[node] = value;
             }
-
-            if (value != null && value is BindableObject)
-                NameScope.SetNameScope(value as BindableObject, node.Namescope);
+            var bindableObject = value as BindableObject;
+            if (bindableObject != null)
+                NameScope.SetNameScope(bindableObject, node.Namescope);
         }
 
         public void Visit(RootNode node, INode parentNode)
index b2bf0d9..2946cb4 100644 (file)
@@ -183,18 +183,23 @@ namespace Tizen.NUI.BaseComponents
         {
             unsafe
             {
-                if (textures != null && sizeof(IntPtr) * textures.Count > 0)
+                
+                if (textures != null)
                 {
-                    IntPtr unmanagedPointer = Marshal.AllocHGlobal(checked(sizeof(IntPtr) * textures.Count));
-                    IntPtr[] texturesArray = new IntPtr[textures.Count];
-                    for (int i = 0; i < textures.Count; i++)
+                    int intptrBytes = checked(sizeof(IntPtr) * textures.Count);
+                    if (intptrBytes>0)
                     {
-                        texturesArray[i] = HandleRef.ToIntPtr(Texture.getCPtr(textures[i]));
-                    }
-                    System.Runtime.InteropServices.Marshal.Copy(texturesArray, 0, unmanagedPointer, textures.Count);
+                        IntPtr unmanagedPointer = Marshal.AllocHGlobal(intptrBytes);
+                        IntPtr[] texturesArray = new IntPtr[textures.Count];
+                        for (int i = 0; i < textures.Count; i++)
+                        {
+                            texturesArray[i] = HandleRef.ToIntPtr(Texture.getCPtr(textures[i]));
+                        }
+                        System.Runtime.InteropServices.Marshal.Copy(texturesArray, 0, unmanagedPointer, textures.Count);
 
-                    Interop.GLView.GlViewBindTextureResources(SwigCPtr, unmanagedPointer, textures.Count);
-                    Marshal.FreeHGlobal(unmanagedPointer);
+                        Interop.GLView.GlViewBindTextureResources(SwigCPtr, unmanagedPointer, textures.Count);
+                        Marshal.FreeHGlobal(unmanagedPointer);
+                    }
                 }
             }
         }