[tex-k] Re: Bug#358330: [tex-live] KPSE_DOT in fmtutil: Why set to `pwd`?

Julian Gilbey jdg at polya.uklinux.net
Tue Mar 28 11:29:58 CEST 2006


On Mon, Mar 27, 2006 at 01:40:56PM -0600, Karl Berry wrote:
>     I think that the correct solution is to replace the final default else
>     with the conditional test:
> 
>         } else if (elt[0] != 0) {
>           /* empty components can appear in TEXMFCNF; we skip over these */
> 
> Sounds reasonable to me.  Thomas, Olaf?

Oops.  When actually testing, compiling and then running the code, I
get lots of error messages like:

*** glibc detected *** double free or corruption (!prev): 0x0804d690 ***

This next patch does the job correctly.  An alternative, simpler,
patch follows below, which does not remove the empty path element.

--- tetex-bin/texk/kpathsea/expand.c	2006-02-16 10:58:10.000000000 +0000
+++ tetex-bin-test/texk/kpathsea/expand.c	2006-03-28 09:53:24.000000000 +0100
@@ -82,6 +82,7 @@
 
   for (elt = kpse_path_element (path); elt; elt = kpse_path_element (NULL)) {
     string save_ret = ret;
+    boolean ret_copied = true;
     /* We assume that the !! magic is only used on absolute components.
        Single "." gets special treatment, as does "./" or its equivalent. */
     if (kpse_absolute_p (elt, false) || (elt[0] == '!' && elt[1] == '!')) {
@@ -91,11 +92,14 @@
 #ifndef VMS
     } else if (elt[0] == '.' && IS_DIR_SEP(elt[1])) {
       ret = concatn (ret, kpse_dot, elt + 1, ENV_SEP_STRING, NULL);
-    } else {
+    } else if (*elt) {
       ret = concatn (ret, kpse_dot, DIR_SEP_STRING, elt, ENV_SEP_STRING, NULL);
 #endif
+    } else {
+      ret_copied = false;
     }
-    free (save_ret);
+    if (ret_copied)
+      free (save_ret);
   }
 
 #ifdef MSDOS


This one is simpler and does not remove the empty path element.

--- tetex-bin/texk/kpathsea/expand.c	2006-02-16 10:58:10.000000000 +0000
+++ tetex-bin-test/texk/kpathsea/expand.c	2006-03-28 10:13:27.000000000 +0100
@@ -84,7 +84,8 @@
     string save_ret = ret;
     /* We assume that the !! magic is only used on absolute components.
        Single "." gets special treatment, as does "./" or its equivalent. */
-    if (kpse_absolute_p (elt, false) || (elt[0] == '!' && elt[1] == '!')) {
+    if (kpse_absolute_p (elt, false) || (elt[0] == '!' && elt[1] == '!') ||
+        ! *elt) {
       ret = concat3(ret, elt, ENV_SEP_STRING);
     } else if (elt[0] == '.' && elt[1] == 0) {
       ret = concat3 (ret, kpse_dot, ENV_SEP_STRING);


   Julian


More information about the tex-k mailing list