make/tests/scripts/features/expand
Paul Smith 04f4c2b8d9 [SV 64124] Avoid stack overflows for large command lines
Modify areas dealing with large command lines to use the heap rather
than relying on alloca / stack space.

* src/main.c (main): Allocate potentially large buffers with xmalloc.
(decode_env_switches): Ditto.
* src/function.c (func_error): Replace alloca with xmalloc/free.
* tests/scripts/features/expand: Add a newline for readable diffs.
2023-06-19 13:27:50 -04:00

26 lines
756 B
Perl

# -*-perl-*-
$description = "Test variable expansion.";
# sv 64124.
# Expand a variable whose value exceeds 200 bytes.
# 200 is the initial size of variable_buffer.
# Value bigger than 200 bytes causes a realloc of variable_buffer.
# In this test the variable being expanded is MAKEFLAGS and its value occupies
# 12, 600 and 120000 bytes.
my $s = "hello_world\n";
my @mult = (1, 50, 10000);
for my $m (@mult) {
my $answer = $s x $m;
$ENV{'MAKEFLAGS'} = " -- hello=$answer";
run_make_test(q!
$(info x$(hello)y)
all:
!,
'', "x${answer}y\n#MAKE#: Nothing to be done for 'all'.\n");
}
# This tells the test driver that the perl test script executed properly.
1;