Add error handling for context.InputFile.Seek operation

This commit is contained in:
Paul van Brouwershaven
2024-07-07 16:37:29 +02:00
committed by Paul van Brouwershaven
parent a0da9873d4
commit 08b31dc8f9

View File

@@ -29,10 +29,15 @@ func (context *SignContext) writeXref() error {
}
func (context *SignContext) writeXrefTable() error {
// Seek to the start of the xref table
_, err := context.InputFile.Seek(context.PDFReader.XrefInformation.StartPos, 0)
if err != nil {
return fmt.Errorf("failed to seek to xref table: %w", err)
}
// Read the existing xref table
context.InputFile.Seek(context.PDFReader.XrefInformation.StartPos, 0)
xrefContent := make([]byte, context.PDFReader.XrefInformation.Length)
_, err := context.InputFile.Read(xrefContent)
_, err = context.InputFile.Read(xrefContent)
if err != nil {
return fmt.Errorf("failed to read xref table: %w", err)
}