提交 3b43d10f 编写于 作者: R Rich Felker

fdopen should set errno when it fails due to invalid mode string

上级 57d5fff5
......@@ -7,7 +7,10 @@ FILE *__fdopen(int fd, const char *mode)
int plus = !!strchr(mode, '+');
/* Check for valid initial mode character */
if (!strchr("rwa", *mode)) return 0;
if (!strchr("rwa", *mode)) {
errno = EINVAL;
return 0;
}
/* Allocate FILE+buffer or fail */
if (!(f=malloc(sizeof *f + UNGET + BUFSIZ))) return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册