mirror of
https://github.com/git/git.git
synced 2026-01-31 13:03:13 +00:00
git-wrapper: fix interpolation with short values
To be precise: when the value of the environment variable is shorter than its name, we have to move the remaining bytes *after* expanding the environment variable: we would look for the wrong name otherwise. When the value is longer than the name, we still need to move the bytes out of the way first, to avoid overwriting them with the interpolated text. This fixes https://github.com/git-for-windows/git/issues/509 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
@@ -269,8 +269,10 @@ static LPWSTR expand_variables(LPWSTR buffer, size_t alloc)
|
||||
if (delta > 0)
|
||||
memmove(atat2 + delta, atat2, move_len);
|
||||
len += delta;
|
||||
save = atat[env_len - 1];
|
||||
save = atat[env_len - 1 + (delta < 0 ? -delta : 0)];
|
||||
GetEnvironmentVariable(atat + 2, atat, env_len);
|
||||
if (delta < 0)
|
||||
memmove(atat2 + delta, atat2, move_len);
|
||||
atat[env_len - 1] = save;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user