Skip to content

Commit 73e3d71

Browse files
committed
pdf_io: fix initialization of the new PDF output state struct when running the XeTeX engine
1 parent 74878ed commit 73e3d71

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

crates/pdf_io/pdf_io/dpx-pdfobj.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,18 @@ struct pdf_out {
232232
* object as a static variable. */
233233
static pdf_out pout;
234234

235+
/* Tectonic: during the XeTeX pass, if a PDF is loaded as an image,
236+
* the current_output can be accessed without init_pdf_out_struct having
237+
* been called. So we add a flag to ensure that it's always initialized. */
238+
static int tectonic_pout_initialized = 0;
239+
static void init_pdf_out_struct (pdf_out *p);
240+
235241
static pdf_out *
236242
current_output (void)
237243
{
244+
if (!tectonic_pout_initialized)
245+
init_pdf_out_struct(&pout);
246+
238247
return &pout;
239248
}
240249

@@ -275,6 +284,7 @@ init_pdf_out_struct (pdf_out *p)
275284

276285
p->free_list = NEW((PDF_NUM_INDIRECT_MAX+1)/8, char);
277286
memset(p->free_list, 0, (PDF_NUM_INDIRECT_MAX+1)/8);
287+
tectonic_pout_initialized = 1;
278288
}
279289

280290
static void
@@ -4384,4 +4394,6 @@ pdf_obj_reset_global_state(void)
43844394
p->output.file_position = 0;
43854395
p->output.line_position = 0;
43864396
p->output.compression_saved = 0;
4397+
4398+
tectonic_pout_initialized = 0;
43874399
}

0 commit comments

Comments
 (0)