mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-04 15:40:44 +00:00
Prevent infinite substitution of the empty string by forcing non-
global substitution. In general it's a makefile bug to globally substitute the empty string, but it's a bug in make(1) if a bug in the makefile yields an infinite running time of make(1). Not objected to by: arch@
This commit is contained in:
parent
2ffaffaa6e
commit
597b8f6add
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=109209
|
@ -1349,6 +1349,17 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
cp++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Replacing the empty string for something else when
|
||||
* done globally causes an infinite loop. The only
|
||||
* meaningful substitution of the empty string would
|
||||
* be those anchored by '^' or '$'. Thus, we can
|
||||
* safely turn the substitution into a non-global one
|
||||
* if the LHS is the empty string.
|
||||
*/
|
||||
if (pattern.leftLen == 0)
|
||||
pattern.flags &= ~VAR_SUB_GLOBAL;
|
||||
|
||||
termc = *cp;
|
||||
newStr = VarModify(str, VarSubstitute,
|
||||
(void *)&pattern);
|
||||
|
|
Loading…
Reference in a new issue