[tex-live] pdftex 1.40.4

George N. White III gnwiii at gmail.com
Wed Jul 25 16:27:12 CEST 2007


On 7/23/07, Karl Berry <karl at freefriends.org> wrote:
>     I think it will be better to add the kpse_record_input()
>     when the file is actually opened (not tested):
>
> Indeed.  I applied it, thanks.

I spent a sleepless night thinking about fontmap.c.  The problem
is that"free(l)" can be called after "l" is modified, but "free()" should
only be called for a malloc() result.  The obvious fix is just:

  free(l) --> free(orig_l)

but I was a bit worried that there might be some problem with
the flow control such that free() shouldn't be used.  The only 2
bits of a line that need to be saved are the "tokens" alias and
filename, but the token function handles the allocation, so for
once I'm convinced the obvious fix will work.

One other quibble: when pdftex crashes, the .fls file is often
left incomplete.  If -recorder is simply a debugging tool, the
buffer should be flushed for each file so you get a hint of
which file might be responsible.

Here is a patch that combines both fixes, and beefs up the hint
about allocation in the comment.

*** fontmap.c.orig	Sun Aug 21 09:00:00 2005
--- fontmap.c	Wed Jul 25 10:42:03 2007
***************
*** 28,33 ****
--- 28,34 ----
  #include <kpathsea/line.h>
  #include <kpathsea/pathsearch.h>
  #include <kpathsea/str-list.h>
+ #include <kpathsea/recorder.h>
  #include <kpathsea/tex-file.h>

  /* We have one and only one fontmap, so may as well make it static
***************
*** 81,90 ****
    char *orig_l;
    unsigned map_lineno = 0;
    FILE *f = xfopen (map_filename, FOPEN_R_MODE);
!
    while ((orig_l = read_line (f)) != NULL) {
      string filename;
!     string l = orig_l;
      string comment_loc = strrchr (l, '%');
      if (!comment_loc) {
        comment_loc = strstr (l, "@c");
--- 82,94 ----
    char *orig_l;
    unsigned map_lineno = 0;
    FILE *f = xfopen (map_filename, FOPEN_R_MODE);
!
!   if (kpse_record_input)
!     kpse_record_input (map_filename);
!
    while ((orig_l = read_line (f)) != NULL) {
      string filename;
!     string l = orig_l; /* save original pointer for free() */
      string comment_loc = strrchr (l, '%');
      if (!comment_loc) {
        comment_loc = strstr (l, "@c");
***************
*** 132,143 ****

        } else {
          /* We've got everything.  Insert the new entry.  They were
!            already dynamically allocated, so don't bother with xstrdup.  */
          hash_insert_normalized (&map, alias, filename);
        }
      }

!     free (l);
    }

    xfclose (f, map_filename);
--- 136,148 ----

        } else {
          /* We've got everything.  Insert the new entry.  They were
!            already dynamically allocated by token(), so don't
!            bother with xstrdup.  */
          hash_insert_normalized (&map, alias, filename);
        }
      }

!     free (orig_l);
    }

    xfclose (f, map_filename);

 --------------------------------------------------------------------------------------------


-- 
George N. White III <aa056 at chebucto.ns.ca>
Head of St. Margarets Bay, Nova Scotia


More information about the tex-live mailing list