return o;
}
+#endif /* !DD_GROW_VIA_BLOCKHOOK */
+
static I32 dd_filter_realloc(pTHX_ int idx, SV *sv, int maxlen)
{
const I32 count = FILTER_READ(idx+1, sv, maxlen);
return count;
}
-#endif /* !DD_GROW_VIA_BLOCKHOOK */
-
static int dd_handle_const(pTHX_ char *name) {
switch (PL_lex_inwhat) {
case OP_QR:
hook_op_check(OP_CONST, dd_ck_const, NULL);
#endif /* !DD_CONST_VIA_RV2CV */
}
-#if !DD_GROW_VIA_BLOCKHOOK
filter_add(dd_filter_realloc, NULL);
-#endif /* !DD_GROW_VIA_BLOCKHOOK */
char*
get_linestr()
--- /dev/null
+use strict;
+use warnings;
+use Test::More tests => 1;
+BEGIN {
+ require Devel::Declare;
+ Devel::Declare->setup_for(__PACKAGE__, {
+ class => {
+ const => sub {
+ my ($kw, $off) = @_;
+ $off += Devel::Declare::toke_move_past_token($off);
+ $off += Devel::Declare::toke_skipspace($off);
+ die unless substr(Devel::Declare::get_linestr(), $off, 1) eq '{';
+ my $l = Devel::Declare::get_linestr();
+ substr $l, $off + 1, 0, 'pass q[injected];' . (';' x 1000);
+ Devel::Declare::set_linestr($l);
+ my $class = sub (&) { $_[0]->() };
+ no strict 'refs';
+ *{ $kw } = $class;
+ },
+ },
+ });
+}
+class {};
--- /dev/null
+use strict;
+use warnings;
+use Test::More tests => 1;
+use t::early1_x;
+class {};
--- /dev/null
+package t::early1_x;
+use strict;
+use warnings;
+sub import {
+ require Devel::Declare;
+ my $caller = caller();
+ Devel::Declare->setup_for($caller, {
+ class => {
+ const => sub {
+ my ($kw, $off) = @_;
+ $off += Devel::Declare::toke_move_past_token($off);
+ $off += Devel::Declare::toke_skipspace($off);
+ die unless substr(Devel::Declare::get_linestr(), $off, 1) eq '{';
+ my $l = Devel::Declare::get_linestr();
+ substr $l, $off + 1, 0, 'pass q[injected];' . (';' x 1000);
+ Devel::Declare::set_linestr($l);
+ my $class = sub (&) { $_[0]->() };
+ no strict 'refs';
+ *{ "${caller}::$kw" } = $class;
+ },
+ },
+ });
+}
+
+1;