From ad1680cb05f76fbd99712e91ce623501db51a4e0 Mon Sep 17 00:00:00 2001 From: Ken Sharp Date: Tue, 20 Dec 2022 15:22:15 +0000 Subject: GhostPDF - check an allocation Desk-checking for OSS-fuzz 54436 I couldn't see how the problem can occur, but I do see that we fail to check an allocation. Add code to check for that and return an error if it happens. --- pdf/pdf_xref.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'pdf/pdf_xref.c') diff --git a/pdf/pdf_xref.c b/pdf/pdf_xref.c index 6aa5296e1..b73f2cd5d 100644 --- a/pdf/pdf_xref.c +++ b/pdf/pdf_xref.c @@ -68,6 +68,9 @@ static int read_xref_stream_entries(pdf_context *ctx, pdf_c_stream *s, int64_t f field_width = W[2]; Buffer = gs_alloc_bytes(ctx->memory, field_width, "read_xref_stream_entry working buffer"); + if (Buffer == NULL) + return_error(gs_error_VMerror); + for (i=first;i<=last; i++){ /* Defaults if W[n] = 0 */ type = 1; -- cgit v1.2.1