[NUI] Fix svace issue of Marshal.Copy
authorXianbing Teng <xb.teng@samsung.com>
Mon, 18 Dec 2023 12:03:31 +0000 (20:03 +0800)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 9 Jan 2024 09:23:06 +0000 (18:23 +0900)
src/Tizen.NUI/src/public/BaseComponents/DirectRenderingGLView.cs

index 63dbda6..055c241 100644 (file)
@@ -183,22 +183,21 @@ namespace Tizen.NUI.BaseComponents
         {
             unsafe
             {
-                
                 if (textures != null)
                 {
                     int count = textures.Count;
-                    int intptrBytes = checked(sizeof(IntPtr) * count);
-                    if (intptrBytes>0)
+                    int intptrBytes = checked(Marshal.SizeOf(typeof(IntPtr)) * count);
+                    if (intptrBytes > 0)
                     {
-                        IntPtr unmanagedPointer = Marshal.AllocHGlobal(intptrBytes);
                         IntPtr[] texturesArray = new IntPtr[count];
                         for (int i = 0; i < count; i++)
                         {
                             texturesArray[i] = HandleRef.ToIntPtr(Texture.getCPtr(textures[i]));
                         }
-                        Marshal.Copy(texturesArray, 0, unmanagedPointer, count);
+                        IntPtr unmanagedPointer = Marshal.AllocHGlobal(intptrBytes);
+                        Marshal.Copy(texturesArray, 0, unmanagedPointer, texturesArray.Length);
 
-                        Interop.GLView.GlViewBindTextureResources(SwigCPtr, unmanagedPointer, count);
+                        Interop.GLView.GlViewBindTextureResources(SwigCPtr, unmanagedPointer, texturesArray.Length);
                         Marshal.FreeHGlobal(unmanagedPointer);
                     }
                 }