[metapost] Uninitialized variable sometimes causing malformed TFM files

Marcel Krüger tex at 2krueger.de
Sat Mar 16 18:04:03 CET 2019


Hi,

the `indep_value` of `mp->zero_val` is never initialized, but it is used the index written into the
depth / ... fields in the TFM files for glyphs with zero depth/.... This causes malformed TFM files.

On my system the TFM corruption can be observed when using LuaTeX to build

\directlua{
local find_file
do
  local kpse = kpse.new('lualatex', 'mpost')
  find_file = function(name, mode, type)
    return mode == 'w' and name or kpse:find_file(name, type) or (type == 'mp' and kpse:find_file(name, 'mf'))
  end
end
local mp = mplib.new{
  job_name = 'cmr10',
  find_file = find_file,
  math_mode = 'scaled',
}
local result = mp:execute'input mfplain;mode:=localfont;input cmr10.mf;'
print(result.term)
}
\bye

Using standalone MetaPost I could not trigger this and the problem does not appear with the
LuaTeX binary from TeXLive binary from pretest, but custom built luatex versions from both the experimental
and the trunk branch showed the problem. The luatex binary available through the contextgarden seems to be affected too.

The problem can be fixed by adding

set_indep_value (mp->zero_val, 0);

below

@ @<Initialize table entries@>=
mp->zero_val = mp_get_value_node (mp);
set_value_number (mp->zero_val, zero_t);

in mp.w (Around line 33774)


Best regards
Marcel Krüger




More information about the metapost mailing list