Skip to content

Commit 6108c0e

Browse files
committed
add check for fgets value
1 parent 665900d commit 6108c0e

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)