Skip to content

Commit 2056872

Browse files
authored
Merge pull request #36 from mcpcpc/fgets
add check for fgets value
2 parents 665900d + 6108c0e commit 2056872

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kirc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,10 @@ handle_user_input(void) {
231231

232232
char usrin[MSG_MAX], *tok;
233233

234-
fgets(usrin, MSG_MAX, stdin);
234+
if (fgets(usrin, MSG_MAX, stdin) == NULL) {
235+
perror("fgets");
236+
exit(1);
237+
}
235238

236239
size_t msg_len = strlen(usrin);
237240
if (usrin[msg_len - 1] == '\n') {

0 commit comments

Comments
 (0)