Free after getline(), even if fail, and catch eof() on el9

getline() allocates the space for the return value even if there is an
error, so when it returns an error, we still have to free() it.

In el9, when reading stdin we will get errno=0 returned (no error) when
we hit the end of stdin. This behavior is different from el7/8. We don't
want to throw an error here to avoid failing the test, since it doesn't.

Signed-off-by: Auke Kok <auke.kok@versity.com>
This commit is contained in:
Auke Kok
2024-02-13 13:02:55 -08:00
parent 6d42d260cf
commit ac00f5cedb

View File

@@ -385,7 +385,8 @@ static int parse_stdin_in_fn(int fd, struct scoutfs_ioctl_quota_rule *irules, si
ret = getline(&line, &size, stdin);
if (ret < 0) {
if (errno == ENOENT)
free(line);
if ((errno == ENOENT) || (errno == 0))
return 0;
ret = -errno;