initialized. This means that if the last char in the prompt is '%' and the
first char is 'h' or 'u' a extra copy of the host or user name would be
copied, for which space had not been allocated.
if (subst) {
new_prompt = (char *) emalloc(len + 1);
- for (p = old_prompt, np = new_prompt; *p; p++) {
+ for (p = old_prompt, np = new_prompt, lastchar = '\0'; *p; p++) {
if (lastchar == '%' && (*p == 'h' || *p == 'u' || *p == '%')) {
- /* substiture user/host name */
+ /* substitute user/host name */
if (*p == 'h') {
np--;
strcpy(np, user_shost);