[NUI] Fix svace issue of buffer exceed size
authorXianbing Teng <xb.teng@samsung.com>
Mon, 1 Apr 2024 11:02:01 +0000 (19:02 +0800)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 12 Apr 2024 05:20:38 +0000 (14:20 +0900)
src/Tizen.NUI.Wearable/src/public/Title.cs
src/Tizen.NUI/src/internal/FrameBroker/FrameBrokerBase.cs

index dc86d9cc63cb0b8a5f00c3df8a5a61baef539ef7..95876d4bc5c5d7632b3a834412830fccce63bb53 100755 (executable)
@@ -328,16 +328,20 @@ namespace Tizen.NUI.Components
 
             TexturedQuadVertex[] texturedQuadVertexData = new TexturedQuadVertex[4] { vertex1, vertex2, vertex3, vertex4 };
 
-            int length = Marshal.SizeOf(vertex1);
-            IntPtr pA = Marshal.AllocHGlobal(checked(length * 4));
+            int size = Marshal.SizeOf(vertex1);
+            IntPtr pA = Marshal.AllocHGlobal(checked(size * texturedQuadVertexData.Length));
 
             try
             {
-                for (int i = 0; i < 4; i++)
+                for (int i = 0; i < texturedQuadVertexData.Length; i++)
                 {
-                    Marshal.StructureToPtr(texturedQuadVertexData[i], pA + i * length, true);
+                    Marshal.StructureToPtr(texturedQuadVertexData[i], pA + i * size, true);
                 }
-                vertexData.SetData(pA, 4);
+                vertexData.SetData(pA, (uint)texturedQuadVertexData.Length);
+            }
+            catch(Exception e)
+            {
+                Tizen.Log.Error("NUI", "Exception in Title : " + e.Message);
             }
             finally
             {
index 43306791ff79515279f8fc5c10b08a00a4144264..27a35ce076e7d64f26b1e8f951e2f5f883f018b1 100755 (executable)
@@ -312,17 +312,21 @@ namespace Tizen.NUI
 
             TexturedQuadVertex[] texturedQuadVertexData = new TexturedQuadVertex[4] { vertex1, vertex2, vertex3, vertex4 };
 
-            int length = Marshal.SizeOf(vertex1);
-            IntPtr pA = Marshal.AllocHGlobal(checked(length * 4));
+            int size = Marshal.SizeOf(vertex1);
+            IntPtr pA = Marshal.AllocHGlobal(checked(size * texturedQuadVertexData.Length));
 
             try
             {
-                for (int i = 0; i < 4; i++)
+                for (int i = 0; i < texturedQuadVertexData.Length; i++)
                 {
-                    Marshal.StructureToPtr(texturedQuadVertexData[i], pA + i * length, true);
+                    Marshal.StructureToPtr(texturedQuadVertexData[i], pA + i * size, true);
                 }
 
-                vertexBuffer.SetData(pA, 4);
+                vertexBuffer.SetData(pA, (uint)texturedQuadVertexData.Length);
+            }
+            catch(Exception e)
+            {
+                Tizen.Log.Error("NUI", "Exception in FrameBrokerBase : " + e.Message);
             }
             finally
             {