gets_s
discard next input line when (s == NULL)
?This issue has been automatically converted from the original issue lists and some formatting may not have been preserved.
Authors: WG 14, Douglas Walls
Date: 2013-02-11
Reference document: N1673 N1748
Submitted against: C11 / C17
Status: Fixed
Fixed in: C17
Converted from: n2396.htm
gets_s Annex K.3.5.4.1p2 says:
"If there is a runtime-constraint violation, s[0] is set to the null
character, and characters are read and discarded from stdin until a
new-line character is read, or end-of-file or a read error occurs."
The runtime-constraint violation here can be caused by a null "s"
pointer. Should we discard the next input line even if (s == NULL)
?
The way it is written, it looks like the answer is yes. However it is
not clear to us that that was the intent. Note also that s[0] cannot be
set to the null character when s==NULL
.
Comment from WG14 on 2017-11-03:
Apr 2013 meeting
Oct 2013 meeting
s[0]
cannot be set to the null character when s==NULL
has been determined to be resolved by the following changes.In Annex K.3.5.4.1, replace paragraph 3 with the following:
If there is a runtime-constraint violation, characters are read and discarded from
stdin
until a new-line character is read, or end-of-file or a read error occurs, and ifs
is not a null pointers[0]
is set to the null character.