Document: N1748
Date: 2013-08-30
Author: Douglas Walls
Subject: Suggested
Technical Corregendum for DR 429
The original question asked in DR 429 was
The runtime-constraint violation here can be caused by a
null "s"
pointer. Should we discard the next input line even if
(s == NULL) ?
When I wrote DR 429, I had not taken footnote 404) into
account.
404) The gets_s function, unlike the historical gets function,
makes it a runtime-constraint violation for
a line of input to overflow the buffer to store it. Unlike the
fgets function, gets_s maintains a
one-to-one relationship between input lines and successful calls to
gets_s. Programs that use gets
expect such a relationship.
I now believe the answer to the question I posed in DR 429 is
yes.
The other minor issue pointed out in the DR is that that s[0]
cannot be
set to the null character when s==NULL. The following
correction is offered.
Suggested Technical Corrigendum for
DR 429
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
if s is not a null pointer s[0] is set to the null character.