Browse Source

Fixed security vulnerability reported by GitHub code scanning: unvalidated local pointer arithmetic

Marcin Ziąbek 1 year ago
parent
commit
32d6711ab6
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Source/QuestPDF/Skia/SkText.cs

+ 2 - 1
Source/QuestPDF/Skia/SkText.cs

@@ -30,9 +30,10 @@ internal class SkText : IDisposable
         {
             var ptr = (byte*)nativeArray;
             Encoding.UTF8.GetBytes(pText, text.Length, ptr, length);
-            *(ptr + length) = 0; // null termination
         }
         
+        Marshal.WriteByte(nativeArray, length, 0); // null termination
+        
         return nativeArray;
     }