[NUI] Fix svace issue of buffer exceed size
authorXianbing Teng <xb.teng@samsung.com>
Mon, 1 Apr 2024 08:25:13 +0000 (16:25 +0800)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 12 Apr 2024 05:19:36 +0000 (14:19 +0900)
src/Tizen.NUI/src/public/BaseComponents/DirectRenderingGLView.cs

index 2dafb5434e034ae8d362fdddd73ae4b910100dfd..8c3bff9f488bbbae51b18cbd6f6ca5285d6d08d6 100644 (file)
@@ -241,20 +241,23 @@ namespace Tizen.NUI.BaseComponents
                 if (textures != null)
                 {
                     int count = textures.Count;
-                    int intptrBytes = checked(Marshal.SizeOf(typeof(IntPtr)) * count);
-                    if (intptrBytes > 0)
+                    if (count > 0)
                     {
                         IntPtr[] texturesArray = new IntPtr[count];
                         for (int i = 0; i < count; i++)
                         {
                             texturesArray[i] = HandleRef.ToIntPtr(Texture.getCPtr(textures[i]));
                         }
-                        IntPtr unmanagedPointer = Marshal.AllocHGlobal(intptrBytes);
+                        IntPtr unmanagedPointer = Marshal.AllocHGlobal(checked(Marshal.SizeOf(typeof(IntPtr)) * texturesArray.Length));
                         try
                         {
                             Marshal.Copy(texturesArray, 0, unmanagedPointer, texturesArray.Length);
                             Interop.GLView.GlViewBindTextureResources(SwigCPtr, unmanagedPointer, texturesArray.Length);
                         }
+                        catch(Exception e)
+                        {
+                            Tizen.Log.Error("NUI", "Exception in GlViewBindTextureResources : " + e.Message);
+                        }
                         finally
                         {
                             Marshal.FreeHGlobal(unmanagedPointer);