[PATCH] Testcase for another regex bug]
Jakub Jelinek
jakub@redhat.com
Sun Sep 29 14:20:00 GMT 2002
On Sun, Sep 29, 2002 at 09:29:52AM -0400, Jack Howarth wrote:
> Jakub,
> Is it possible any of these compiler warnings could be related
> to some of our remaining regex issues?
>
> make[2]: Entering directory `/home/howarth/libc/posix'
> In file included from regex.c:52:
> regexec.c: In function `search_subexp':
> regexec.c:1573: warning: `node' might be used uninitialized in this function
This one is harmless.
> In file included from regex.c:52:
> regexec.c: In function `sift_states_bkref':
> regexec.c:1672: warning: `err' might be used uninitialized in this function
This one looks like a bug:
err might be set or uninitialized here
local_sctx.last_node = node;
local_sctx.last_str_idx = str_idx;
ret = re_node_set_insert (&local_sctx.limits, enabled_idx);
if (BE (err < 0, 0))
return REG_ESPACE;
err = sift_states_backward (preg, mctx, &local_sctx);
if (BE (err != REG_NOERROR, 0))
return err;
The only place where ret is used is on the above line, the value
is never checked. Furthermore, re_node_set_insert returns int, not
reg_errcode_t and returns -1 in out of memory conditions.
I think it was meant to be:
2002-09-29 Jakub Jelinek <jakub@redhat.com>
* posix/regexec.c (sift_states_bkref): Check ret, not err for
failure.
--- libc/posix/regexec.c.jj 2002-09-28 16:59:27.000000000 +0200
+++ libc/posix/regexec.c 2002-09-29 23:21:19.000000000 +0200
@@ -1770,7 +1770,7 @@ sift_states_bkref (preg, mctx, sctx, str
local_sctx.last_node = node;
local_sctx.last_str_idx = str_idx;
ret = re_node_set_insert (&local_sctx.limits, enabled_idx);
- if (BE (err < 0, 0))
+ if (BE (ret < 0, 0))
return REG_ESPACE;
err = sift_states_backward (preg, mctx, &local_sctx);
if (BE (err != REG_NOERROR, 0))
Jakub
More information about the Libc-alpha
mailing list