mirror of
				git://git.code.sf.net/p/cdesktopenv/code
				synced 2025-03-09 15:50:02 +00:00 
			
		
		
		
	Update comsub-with-alias anti-leak hack (re: fe20311f)
				
					
				
			In the 93v- beta, they add a newline instead of a space. This has fewer side effects as final newlines get stripped. It's still a hack and it would still be nice to have a real fix, but it seems even the AT&T guys couldn't come up with one. src/cmd/ksh93/sh/macro.c: - To somehow avoid a memory leak involving alias substitution, append a linefeed instead of a space to the comsub buffer. src/cmd/ksh93/tests/subshell.sh: - Add test for minor regression caused by the RedHat version.
This commit is contained in:
		
							parent
							
								
									72968eaed6
								
							
						
					
					
						commit
						350b52ea4e
					
				
					 2 changed files with 11 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -2118,7 +2118,7 @@ static void comsubst(Mac_t *mp,register Shnode_t* t, int type)
 | 
			
		|||
			}
 | 
			
		||||
			sfputc(stkp,c);
 | 
			
		||||
		}
 | 
			
		||||
		sfputc(stkp,' '); /* rhbz#982142: a=`some_alias` leaked memory, a=`some_alias ` did not! TODO: non-hack fix */
 | 
			
		||||
		sfputc(stkp,'\n');  /* a=`some_alias` leaked memory, a=`some_alias<LF>` did not! TODO: non-hack fix */
 | 
			
		||||
		c = stktell(stkp);
 | 
			
		||||
		str=stkfreeze(stkp,1);
 | 
			
		||||
		/* disable verbose and don't save in history file */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -950,5 +950,15 @@ v=main
 | 
			
		|||
(v=sub; (d=${ v=shared; }; [[ $v == shared ]]) ) || err_exit "shared comsub in nested subshell wrongly scoped (2)"
 | 
			
		||||
[[ $v == main ]] || err_exit "shared comsub leaks out of subshell (7)"
 | 
			
		||||
 | 
			
		||||
# ======
 | 
			
		||||
# After the memory leak patch for rhbz#982142, this minor regression was introduced:
 | 
			
		||||
# if a backtick command substitution expanded an alias, an extra space was inserted.
 | 
			
		||||
exp='word'
 | 
			
		||||
alias a='print -n wo\'
 | 
			
		||||
got=$(eval 'echo "`a`rd"')
 | 
			
		||||
unalias a
 | 
			
		||||
[[ $got == "$exp" ]] || err_exit 'backtick comsub with alias:' \
 | 
			
		||||
	"expected $(printf %q "$exp"), got $(printf %q "$got")"
 | 
			
		||||
 | 
			
		||||
# ======
 | 
			
		||||
exit $((Errors<125?Errors:125))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue