Skip to content

Commit bb5dd93

Browse files
committed
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
1 parent 159e8d6 commit bb5dd93

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

av.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ array is C<av_len(av) + 1>. Returns -1 if the array is empty.
758758
*/
759759

760760
I32
761-
Perl_av_len(pTHX_ register const AV *av)
761+
Perl_av_len(pTHX_ AV *av)
762762
{
763763
PERL_ARGS_ASSERT_AV_LEN;
764764
assert(SvTYPE(av) == SVt_PVAV);

embed.fnc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Apd |void |av_extend |NN AV *av|I32 key
112112
pR |AV* |av_fake |I32 size|NN SV **strp
113113
ApdR |SV** |av_fetch |NN AV *av|I32 key|I32 lval
114114
Apd |void |av_fill |NN AV *av|I32 fill
115-
ApdR |I32 |av_len |NN const AV *av
115+
ApdR |I32 |av_len |NN AV *av
116116
ApdR |AV* |av_make |I32 size|NN SV **strp
117117
Apd |SV* |av_pop |NN AV *av
118118
ApdoxM |void |av_create_and_push|NN AV **const avp|NN SV *const val

mg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@ int
18951895
Perl_magic_getarylen(pTHX_ SV *sv, const MAGIC *mg)
18961896
{
18971897
dVAR;
1898-
const AV * const obj = (AV*)mg->mg_obj;
1898+
AV * const obj = (AV*)mg->mg_obj;
18991899

19001900
PERL_ARGS_ASSERT_MAGIC_GETARYLEN;
19011901

proto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ PERL_CALLCONV void Perl_av_fill(pTHX_ AV *av, I32 fill)
192192
#define PERL_ARGS_ASSERT_AV_FILL \
193193
assert(av)
194194

195-
PERL_CALLCONV I32 Perl_av_len(pTHX_ const AV *av)
195+
PERL_CALLCONV I32 Perl_av_len(pTHX_ AV *av)
196196
__attribute__warn_unused_result__
197197
__attribute__nonnull__(pTHX_1);
198198
#define PERL_ARGS_ASSERT_AV_LEN \

0 commit comments

Comments
 (0)