From: Xianbing Teng Date: Mon, 18 Dec 2023 12:03:31 +0000 (+0800) Subject: [NUI] Fix svace issue of Marshal.Copy X-Git-Tag: accepted/tizen/unified/20240110.154200~1^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=406bf5771e630d1628b82e863d85961eb7973aeb;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Fix svace issue of Marshal.Copy --- diff --git a/src/Tizen.NUI/src/public/BaseComponents/DirectRenderingGLView.cs b/src/Tizen.NUI/src/public/BaseComponents/DirectRenderingGLView.cs index 63dbda6..055c241 100644 --- a/src/Tizen.NUI/src/public/BaseComponents/DirectRenderingGLView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/DirectRenderingGLView.cs @@ -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); } }