The (i < PROMPTLEN - 1) test added by r300442 in the code for the default

case of \c in the prompt format string is a no-op.  We already passed
this test at the top of the loop, and i has not yet been incremented in
this path.  Change this test to (i < PROMPTLEN - 2).

Reported by:	Coverity
CID:		1008328
Reviewed by:	cem
MFC after:	1 week
This commit is contained in:
Don Lewis 2016-06-01 16:56:29 +00:00
parent 7e77774311
commit eaf2e1e6f7

View File

@ -2063,7 +2063,7 @@ getprompt(void *unused __unused)
*/
default:
ps[i] = '\\';
if (i < PROMPTLEN - 1)
if (i < PROMPTLEN - 2)
ps[++i] = *fmt;
break;
}