+diff --git a/lib/regcomp.c b/lib/regcomp.c

This is okay.

diff --git a/gl/lib/regex_internal.c.diff b/gl/lib/regex_internal.c.diff

This is okay. There is one caller of re_node_set_remove_at, in regexec.c, which might pass SIZE_MAX as the second parameter to re_node_set_remove_at. This works, but I'd make sure this does not happen by doing this:

diff --git a/lib/regexec.c b/lib/regexec.c
index 21a8166..34630fa 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -1913,8 +1913,9 @@
        Idx cur_node = inv_eclosure->elems[ecl_idx];
        if (!re_node_set_contains (&except_nodes, cur_node))
          {
-           Idx idx = re_node_set_contains (dest_nodes, cur_node) - 1;
-           re_node_set_remove_at (dest_nodes, idx);
+           Idx idx = re_node_set_contains (dest_nodes, cur_node);
+           if (idx)
+             re_node_set_remove_at (dest_nodes, idx - 1);
          }
      }
     re_node_set_free (&except_nodes);


However...

diff --git a/gl/lib/regexec.c.diff b/gl/lib/regexec.c.diff

... this is wrong, and in fact the entire castle crumbles because of this patch. Idx i.e. __re_idx_t is size_t, but it replaced int with Paul Eggert's patch to support >2GB subjects and regexes (which Uli rejected upstream).

If you wish, feel free to commit to gnulib the other patches (plus the regexec.c hunk above). However, I think it's better to make a different patch, which defines __re_idx_t as ptrdiff_t. Such a patch would also remove the

  if ((Idx) -1 < 0 || end != REG_MISSING)

condition from regcomp.c which is absent upstream. Also, with this alternative patch the change to regexec.c that I suggested above would be unnecessary.

Paolo


Reply via email to