You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is an issue in the CharacterCodeToGlyphIndex method within the ByteEncodingCMapTable class, which implements the ICMapSubTable interface in the namespace UglyToad.PdfPig.Fonts.TrueType.Tables.CMapSubTables.
The method is encountering a System.IndexOutOfRangeException due to an attempt to access an index outside the bounds of the glyphMapping array. Below is the implementation of the method:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at UglyToad.PdfPig.Fonts.TrueType.Tables.CMapSubTables.ByteEncodingCMapTable.CharacterCodeToGlyphIndex(Int32 characterCode) in D:\..........UglyToad.PdfPig.Fonts\TrueType\Tables\CMapSubTables\ByteEncodingCMapTable.cs:line 57
Exception thrown: 'System.IndexOutOfRangeException' in UglyToad.PdfPig.Fonts.dll
Investigation Insights:
Upon examining the values, it appears that the exception is caused by a discrepancy between GlyphMappingLength and the actual length of the glyphMapping array:
GlyphMappingLength = 256
glyphMapping = {byte[252]}
Attached Document:
I have also attached a document, example.pdf
, which might help in reproducing and investigating the issue further.
Steps to Reproduce:
Use the CharacterCodeToGlyphIndex method with an input characterCode greater than or equal to the length of the glyphMapping array but less than GlyphMappingLength.
The method throws System.IndexOutOfRangeException.
Proposed Solution:
Ensure that both the GlyphMappingLength and the glyphMapping array are synchronized in terms of their lengths to avoid out-of-bounds access, or update the method to validate against the actual length of glyphMapping rather than GlyphMappingLength.
Additional Context:
The issue is observed in the following file:
Issue Description:
There is an issue in the
CharacterCodeToGlyphIndex
method within theByteEncodingCMapTable
class, which implements theICMapSubTable
interface in the namespaceUglyToad.PdfPig.Fonts.TrueType.Tables.CMapSubTables
.The method is encountering a
System.IndexOutOfRangeException
due to an attempt to access an index outside the bounds of theglyphMapping
array. Below is the implementation of the method:Exception Details:
Investigation Insights:
Upon examining the values, it appears that the exception is caused by a discrepancy between
GlyphMappingLength
and the actual length of theglyphMapping
array:GlyphMappingLength = 256
glyphMapping = {byte[252]}
Attached Document:
I have also attached a document, example.pdf
, which might help in reproducing and investigating the issue further.
Steps to Reproduce:
CharacterCodeToGlyphIndex
method with an inputcharacterCode
greater than or equal to the length of theglyphMapping
array but less thanGlyphMappingLength
.System.IndexOutOfRangeException
.Sample Code to Reproduce the Issue:
Proposed Solution:
Ensure that both the
GlyphMappingLength
and theglyphMapping
array are synchronized in terms of their lengths to avoid out-of-bounds access, or update the method to validate against the actual length ofglyphMapping
rather thanGlyphMappingLength
.Additional Context:
The issue is observed in the following file:
Please let me know if you need any further information or clarification.
The text was updated successfully, but these errors were encountered: