[NTG-pdftex] [ pdftex-Bugs-435 ] Wrong file name in error messages of image inclusion (readimage)

noreply at sarovar.org noreply at sarovar.org
Mon Oct 17 19:27:46 CEST 2005

Bugs item #435, was opened at 2005-10-15 01:21
You can respond by visiting: 

Category: Image inclusion
Group: v1.30.0
>Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Heiko Oberdiek (oberdiek)
Assigned to: Martin Schröder (oneiros)
Summary: Wrong file name in error messages of image inclusion (readimage)

Initial Comment:

see the thread "Wrong search path for PDF/PNG/JPG
files" (2005/10/14) in the pdftex mailing list.
Wlodek Bzyl detected a bug regarding image

pdfTeX sometimes prints a wrong file name in image
error messages:
The current directory contains:
pic.jpg (JPG image), pic.jpg.tex (e.g. consisting of
"\relax") and

Then kpse_find_file will find "pic.jpg.tex" (the
automatically adding of ".tex" is sometimes very
annoying) and prints the error message:
  Error: pdftex (file ./pic.jpg): reading image file
Or if the file pic.jpg.tex is longer:
  Error: pdftex (file ./pic.jpg): unknown type of image

In both cases the file name in the error message is
wrong. The error message is thrown by pdftex_fail that
looks for cur_file_name and prints it (utils.c).
However the real image file name can be changed
by kpse_find_file (e.g. adding ".tex"):

    img_name(img) = kpse_find_file(cur_file_name,
                           kpse_tex_format, true);
    if (img_name(img) == NULL)
        pdftex_fail("cannot find image file");

// Here the file name is still correct
// (img_name(img) is NULL)
// But after this, img_name(img) is not NULL and
// contains the used file name, cur_file_name is no
// longer valid.

        pdftex_fail("unknown type of image");
    cur_file_name = NULL;

// checktypebyheader calls pdftex_fail,
// and pdftex_fail is also used
// later, in each case using the wrong cur_file_name.

Fix is easy:
  cur_file_name = img_name(img);
after the NULL check part before checktypebyheader.
There are no memory problems. Before cur_file_name
points to a static buffer, the return value of
makecstring. Thus free must not be used on
cur_file_name. And the memory part of img_name(img)
is not changed.

Yours sincerely
  Heiko <oberdiek at uni-freiburg.de>


Comment By: Martin Schröder (oneiros)
Date: 2005-10-17 19:27

Logged In: YES 

This has been fixed in 1.30.4


You can respond by visiting: 

More information about the ntg-pdftex mailing list