PureBasic 6.40 alpha 4 PurePDF crashes
Posted: Fri Feb 13, 2026 1:24 am
Testing alpha 4, I found a spot in Normeus' PurePDF that causes a crash. This happened with both C and ASM backends.
The line to return the version is highighted when the crash happens.
I am also getting a Debug Quit on OpenDatabase (SQLite) but not consistently. I have been trying to track down the trigger but so far have not been able to do that. No Debug Quit with 6.30 LTS. Still investigating.
The line to return the version is highighted when the crash happens.
Code: Select all
Procedure.l ipdf_EndianL(value.l)
ProcedureReturn (value>>24&$ff)|(value>>8&$ff00)|(value<<24&$ff000000)|(value<<8&$ff0000)
EndProcedure
Procedure.i ipdf_TTF_SearchTagName(*TTF_Memory.TTF_Header,TagName.s)
Protected Version,numTables,searchRange,entrySelector,rangeShift
Protected *OffsetTable.TTF_Header_Table
Protected tag.s,checkSum.l,offset.l,Tlength.l
If *TTF_Memory
Version = ipdf_EndianL(*TTF_Memory\sfnt_version) ;<<<<<<<<<<<< crashes with this line highlighted
numTables = ipdf_EndianW(*TTF_Memory\numTables)
searchRange = ipdf_EndianW(*TTF_Memory\searchRange)
entrySelector = ipdf_EndianW(*TTF_Memory\entrySelector)
rangeShift = ipdf_EndianW(*TTF_Memory\rangeShift)
If Version = $10000 ; 0x00010000 for version 1.0 / can be 'true' or 'typ1' on Apple Systems
*OffsetTable=*TTF_Memory+SizeOf(TTF_Header)
While numTables>0
tag = PeekS(@*OffsetTable\tag,4,#PB_Ascii)
checkSum = ipdf_EndianL(*OffsetTable\checkSum)
offset = ipdf_EndianL(*OffsetTable\offset)
Tlength = ipdf_EndianL(*OffsetTable\length)
;Debug "tag="+tag
;Debug "checkSum="+Hex(checkSum,#PB_Long)
;Debug "offset="+Hex(offset,#PB_Long)
;Debug "Tlength="+Hex(Tlength,#PB_Long)
;Calc.l = ipdf_TTF_CalcTableChecksum(*TTF_Memory+offset,Tlength)
;Debug "Calc="+Hex(Calc,#PB_Long)
;If checkSum <> Calc
; Debug Hex(checkSum,#PB_Long) + "<>" + Hex(Calc,#PB_Long)
;EndIf
If tag = TagName
ProcedureReturn *TTF_Memory+offset
EndIf
*OffsetTable+SizeOf(TTF_Header_Table)
numTables-1
Wend
EndIf
EndIf
EndProcedure