![](https://secure.gravatar.com/avatar/adfff96f4299fb3ee3b199b06eea68da.jpg?s=120&d=mm&r=g)
Bugs item #435, was opened at 2005-10-15 01:21
You can respond by visiting:
http://sarovar.org/tracker/?func=detail&atid=493&aid=435&group_id=106
Category: Image inclusion
Group: None
Status: Open
Resolution: None
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:
Hello,
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
inclusion:
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
test.tex:
\pdfximage{pic.jpg}
\pdfrefximage\pdflastximage
\bye
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
failed
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.
checktypebyheader(img);
checktypebyextension(img);
...
default:
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