From 5c60c08dc221f0c2771e08f2b80607cb52f4845f Mon Sep 17 00:00:00 2001 From: Peter Breitenlohner Date: Tue, 24 Feb 2015 12:39:07 +0000 Subject: texk/dvipdfm-x: Fix a small memory leak git-svn-id: svn://tug.org/texlive/trunk@36368 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dvipdfm-x/ChangeLog | 4 +++- Build/source/texk/dvipdfm-x/dvi.c | 18 ++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'Build/source/texk/dvipdfm-x') diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog index e03a2b29c33..f7dbbb63e73 100644 --- a/Build/source/texk/dvipdfm-x/ChangeLog +++ b/Build/source/texk/dvipdfm-x/ChangeLog @@ -1,6 +1,8 @@ 2015-02-24 Peter Breitenlohner - * dvi.c (dvi_locate_native_font): Avoid buffer overflow. + * dvi.c (dvi_locate_native_font): Avoid sprintf() buffer overrun. + + * dvi.c (dvi_locate_native_font): Fix a small memory leak. 2015-02-21 Khaled Hosny diff --git a/Build/source/texk/dvipdfm-x/dvi.c b/Build/source/texk/dvipdfm-x/dvi.c index f0dd4393d0c..1c8b2f38eff 100644 --- a/Build/source/texk/dvipdfm-x/dvi.c +++ b/Build/source/texk/dvipdfm-x/dvi.c @@ -923,7 +923,7 @@ dvi_locate_native_font (const char *filename, uint32_t index, fontmap_rec *mrec; char *fontmap_key; FILE *fp; - char *path = strdup(filename); + char *path; sfnt *sfont; unsigned offset = 0; struct tt_head_table *head; @@ -933,15 +933,13 @@ dvi_locate_native_font (const char *filename, uint32_t index, if (verbose) MESG("<%s@%.2fpt", filename, ptsize * dvi2pts); - fp = fopen(path, "rb"); - if (!fp && - ((path = dpx_find_opentype_file(filename)) != NULL - || (path = dpx_find_truetype_file(filename)) != NULL - || (path = dpx_find_type1_file(filename)) != NULL - || (path = dpx_find_dfont_file(filename)) != NULL) ) { - fp = fopen(path, "rb"); - } - if (!fp) { + if ((fp = fopen(filename, "rb")) != NULL) + path = strdup(filename); + else if (((path = dpx_find_opentype_file(filename)) == NULL + && (path = dpx_find_truetype_file(filename)) == NULL + && (path = dpx_find_type1_file(filename)) == NULL + && (path = dpx_find_dfont_file(filename)) == NULL) + || (fp = fopen(path, "rb")) == NULL) { ERROR("Cannot proceed without the font: %s", filename); } need_more_fonts(1); -- cgit v1.2.3