From: Nicholas Clark Date: Mon, 27 Oct 2008 20:22:36 +0000 (+0000) Subject: Bugs revealed by replacing (SV *) casts with something that doesn't X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bb5dd93d07e2d54d352e519c7b43ff2d3e5c5f36;p=p5sagit%2Fp5-mst-13.2.git Bugs revealed by replacing (SV *) casts with something that doesn't cast away const - AvFILL() doesn't guarantee that it won't modify the AV * passed to it. So the prototype for Perl_av_len() needs to change, and a const needs to go in Perl_magic_setarraylen(). p4raw-id: //depot/perl@34604 --- diff --git a/av.c b/av.c index b2c1aae..a31a8be 100644 --- a/av.c +++ b/av.c @@ -758,7 +758,7 @@ array is C. Returns -1 if the array is empty. */ I32 -Perl_av_len(pTHX_ register const AV *av) +Perl_av_len(pTHX_ AV *av) { PERL_ARGS_ASSERT_AV_LEN; assert(SvTYPE(av) == SVt_PVAV); diff --git a/embed.fnc b/embed.fnc index d9b5f22..78c4f19 100644 --- a/embed.fnc +++ b/embed.fnc @@ -112,7 +112,7 @@ Apd |void |av_extend |NN AV *av|I32 key pR |AV* |av_fake |I32 size|NN SV **strp ApdR |SV** |av_fetch |NN AV *av|I32 key|I32 lval Apd |void |av_fill |NN AV *av|I32 fill -ApdR |I32 |av_len |NN const AV *av +ApdR |I32 |av_len |NN AV *av ApdR |AV* |av_make |I32 size|NN SV **strp Apd |SV* |av_pop |NN AV *av ApdoxM |void |av_create_and_push|NN AV **const avp|NN SV *const val diff --git a/mg.c b/mg.c index b34257d..643ec7e 100644 --- a/mg.c +++ b/mg.c @@ -1895,7 +1895,7 @@ int Perl_magic_getarylen(pTHX_ SV *sv, const MAGIC *mg) { dVAR; - const AV * const obj = (AV*)mg->mg_obj; + AV * const obj = (AV*)mg->mg_obj; PERL_ARGS_ASSERT_MAGIC_GETARYLEN; diff --git a/proto.h b/proto.h index ca19956..0d7d9a4 100644 --- a/proto.h +++ b/proto.h @@ -192,7 +192,7 @@ PERL_CALLCONV void Perl_av_fill(pTHX_ AV *av, I32 fill) #define PERL_ARGS_ASSERT_AV_FILL \ assert(av) -PERL_CALLCONV I32 Perl_av_len(pTHX_ const AV *av) +PERL_CALLCONV I32 Perl_av_len(pTHX_ AV *av) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_AV_LEN \