Skip to content

Commit d7e7549

Browse files
committed
fix type of Perl_magic_getarylen
This function is used as part of PL_magic_vtables, so its type must be 'int (pTHX_ SV *, MAGIC *)' exactly (no const). With the right type, we no longer need an ad-hoc cast in mg_vtables.h, which means we no longer need the 'const' code in regen/mg_vtable.pl, which was a special case used by this one function only. Should fix ASan complaints about functions being called with incorrect types.
1 parent 40065a2 commit d7e7549

File tree

5 files changed

+5
-11
lines changed

5 files changed

+5
-11
lines changed

embed.fnc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1909,7 +1909,7 @@ p |int |magic_freeutf8 |NN SV *sv \
19091909
p |int |magic_get |NN SV *sv \
19101910
|NN MAGIC *mg
19111911
p |int |magic_getarylen|NN SV *sv \
1912-
|NN const MAGIC *mg
1912+
|NN MAGIC *mg
19131913
p |int |magic_getdebugvar \
19141914
|NN SV *sv \
19151915
|NN MAGIC *mg

mg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2364,7 +2364,7 @@ Perl_magic_setdbline(pTHX_ SV *sv, MAGIC *mg)
23642364
}
23652365

23662366
int
2367-
Perl_magic_getarylen(pTHX_ SV *sv, const MAGIC *mg)
2367+
Perl_magic_getarylen(pTHX_ SV *sv, MAGIC *mg)
23682368
{
23692369
AV * const obj = MUTABLE_AV(mg->mg_obj);
23702370

mg_vtable.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

regen/mg_vtable.pl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,6 @@ BEGIN
245245
# prefix the vtable with the specified entry (e.g. '#ifdef FOO')
246246
# and suffix it with '#else { 0, 0, 0, 0, 0, 0, 0, 0 } #endif'
247247
#
248-
# const
249-
# special-case cast a 'get' function whose signature expects
250-
# a pointer to constant magic, so that it can be added to a vtable
251-
# which expects pointers to functions without the 'const'.
252-
#
253248
# get
254249
# set
255250
# len
@@ -277,7 +272,7 @@ BEGIN
277272
'dbline' => {set => 'setdbline'},
278273
'isa' => {set => 'setisa', clear => 'clearisa'},
279274
'isaelem' => {set => 'setisa'},
280-
'arylen' => {get => 'getarylen', set => 'setarylen', const => 1},
275+
'arylen' => {get => 'getarylen', set => 'setarylen'},
281276
'arylen_p' => {clear => 'cleararylen_p', free => 'freearylen_p'},
282277
'mglob' => {set => 'setmglob',
283278
free => 'freemglob' },
@@ -528,7 +523,6 @@ BEGIN
528523
$data->{$_} ? "Perl_magic_$data->{$_}" : 0;
529524
} qw(get set len clear free copy dup local);
530525

531-
$funcs[0] = "(int (*)(pTHX_ SV *, MAGIC *))" . $funcs[0] if $data->{const};
532526
my $funcs = join ", ", @funcs;
533527

534528
# Because we can't have a , after the last {...}

0 commit comments

Comments
 (0)