From 1039639b6e79f17f14c04253b0f29ef6a4c1e2fe Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Sat, 18 Jul 2020 03:02:46 +0000 Subject: Fix a bug that error cleanup routine can be called recursively (S. Hirata). git-svn-id: svn://tug.org/texlive/trunk@55865 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dvipdfm-x/ChangeLog | 7 +++++++ Build/source/texk/dvipdfm-x/dvipdfmx.c | 6 +++++- Build/source/texk/dvipdfm-x/pdfximage.c | 17 +++++++++++++++++ Build/source/texk/dvipdfm-x/pdfximage.h | 4 +++- 4 files changed, 32 insertions(+), 2 deletions(-) (limited to 'Build') diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog index 07e73ebceff..8821f2b2293 100644 --- a/Build/source/texk/dvipdfm-x/ChangeLog +++ b/Build/source/texk/dvipdfm-x/ChangeLog @@ -1,3 +1,10 @@ +2020-07-18 Shunsaku Hirata + + * dvipdfmx.c, pdfximage.[ch]: Don't call ordinary functions + such as pdf_close_images() which can call ERROR() in + error_cleanup(). This can result in a recursive call of + error_cleanup(). + 2020-07-11 Shunsaku Hirata * pdfdev.c, pdfdoc.c, pdfdraw.[ch], pdfobj.[ch], spc_pdfm.c: diff --git a/Build/source/texk/dvipdfm-x/dvipdfmx.c b/Build/source/texk/dvipdfm-x/dvipdfmx.c index 21b0e92725d..f67c7deb7dd 100644 --- a/Build/source/texk/dvipdfm-x/dvipdfmx.c +++ b/Build/source/texk/dvipdfm-x/dvipdfmx.c @@ -870,7 +870,11 @@ system_default (void) void error_cleanup (void) { - pdf_close_images(); /* delete temporary files */ + /* Fixed a stupid bug... + * Please don't put an ordinay function which may call ERROR() inside it. + * It may result in error cleanup routine being called recursively. + */ + pdf_error_cleanup_cache(); /* delete temporary files */ pdf_error_cleanup(); if (pdf_filename) { if (pdf_get_output_file()) { diff --git a/Build/source/texk/dvipdfm-x/pdfximage.c b/Build/source/texk/dvipdfm-x/pdfximage.c index ef6282e80ad..be8e9a4da55 100644 --- a/Build/source/texk/dvipdfm-x/pdfximage.c +++ b/Build/source/texk/dvipdfm-x/pdfximage.c @@ -1056,3 +1056,20 @@ static int check_for_mp (FILE *image_file) return ((try_count > 0) ? 1 : 0); } + +/* ERROR() can't be used here otherwise the cleanup routine is recursively called. */ +#undef ERROR +void +pdf_error_cleanup_cache (void) +{ + struct ic_ *ic = &_ic; + int i; + pdf_ximage *I; + + for (i = 0; i < ic->count; i++) { + I = &ic->ximages[i]; + if (I->attr.tempfile) { + dpx_delete_temp_file(I->filename, false); /* temporary filename freed here */ + } + } +} diff --git a/Build/source/texk/dvipdfm-x/pdfximage.h b/Build/source/texk/dvipdfm-x/pdfximage.h index b174c44655f..fa29663ff70 100644 --- a/Build/source/texk/dvipdfm-x/pdfximage.h +++ b/Build/source/texk/dvipdfm-x/pdfximage.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2007-2018 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007-2020 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks @@ -102,4 +102,6 @@ pdf_ximage_set_attr (int xobj_id, /* Migrated from pdfobj.h. Those are not PDF object related... */ +extern void pdf_error_cleanup_cache (void); + #endif /* _PDFXIMAGE_H_ */ -- cgit v1.2.3