develooper Front page | perl.perl5.porters | Postings from April 2006

Re: [PATCH] regcomp.c: possible way to convince Coverity that listsv is always non-NULL

Thread Previous
From:
Nicholas Clark
Date:
April 11, 2006 13:20
Subject:
Re: [PATCH] regcomp.c: possible way to convince Coverity that listsv is always non-NULL
Message ID:
20060411201953.GH32132@plum.flirble.org
On Tue, Apr 11, 2006 at 10:51:01PM +0300, Jarkko Hietaniemi wrote:
> --- regcomp.c.dist	2006-04-11 22:28:55.000000000 +0300
> +++ regcomp.c	2006-04-11 22:47:39.000000000 +0300
> @@ -4675,9 +4675,10 @@
>  	if (LOC)
>  	    ANYOF_FLAGS(ret) |= ANYOF_LOCALE;
>  	ANYOF_BITMAP_ZERO(ret);
> -	listsv = newSVpvs("# comment\n");
>      }
>  
> +    listsv = newSVpvs("# comment\n");
> +
>      nextvalue = RExC_parse < RExC_end ? UCHARAT(RExC_parse) : 0;
>  
>      if (!SIZE_ONLY && POSIXCC(nextvalue))
> @@ -5404,6 +5405,9 @@
>  	ARG_SET(ret, n);
>      }
>  
> +    if (SIZE_ONLY)
> +	SvREFCNT_dec(listsv);
> +
>      return ret;
>  }

But Coverity is wrong on this one, isn't it? It's a false positive, because
SIZE_ONLY has to remain false throughout, as far as I can work out.

Oh. But it's assuming that at some point C<RExC_emit += ANYOF_SKIP> could
cause RExC_emit to become equal to &PL_regdummy, and so SIZE_ONLY become
true. In which case it's fair.

Would it be better to assign &PL_sv_undef to listsv? That would avoid creating
an unneeded scalar.

Nicholas Clark

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About