Skip to content

Commit 41ad163

Browse files
committed
engine_xetex: close input files on abnormal exit
1 parent 91447de commit 41ad163

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

crates/engine_xetex/xetex/xetex-ini.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3510,6 +3510,12 @@ tt_cleanup(void) {
35103510
}
35113511
}
35123512

3513+
for (int i = 1; i <= in_open; i++) {
3514+
if (input_file[i] != NULL) {
3515+
u_close(input_file[i]);
3516+
}
3517+
}
3518+
35133519
// Free the big allocated arrays
35143520
free(buffer);
35153521
free(nest);

crates/engine_xetex/xetex/xetex-xetex0.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5040,18 +5040,21 @@ void begin_file_reading(void)
50405040
cur_input.synctex_tag = 0;
50415041
}
50425042

5043-
void end_file_reading(void)
5043+
void
5044+
end_file_reading(void)
50445045
{
50455046
first = cur_input.start;
50465047
line = line_stack[cur_input.index];
5047-
if ((cur_input.name == 18) || (cur_input.name == 19))
5048+
5049+
if (cur_input.name == 18 || cur_input.name == 19) {
50485050
pseudo_close();
5049-
else if (cur_input.name > 17)
5051+
} else if (cur_input.name > 17) {
50505052
u_close(input_file[cur_input.index]);
5051-
{
5052-
input_ptr--;
5053-
cur_input = input_stack[input_ptr];
5053+
input_file[cur_input.index] = NULL;
50545054
}
5055+
5056+
input_ptr--;
5057+
cur_input = input_stack[input_ptr];
50555058
in_open--;
50565059
}
50575060

0 commit comments

Comments
 (0)