statd: remove double-close of file descriptor after fclose

When fdopen() succeeds, the FILE stream takes ownership of the file
descriptor.  Calling fclose() automatically closes the underlying fd, so
the subsequent close(fd) calls were double-close bugs that could cause
undefined behavior.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2026-01-24 18:08:32 +01:00
parent 5f737ed145
commit 496eda7eb2
+1 -3
View File
@@ -96,7 +96,6 @@ static int ly_add_yanger_data(const struct ly_ctx *ctx, struct lyd_node **parent
if (err) {
ERROR("Error, running yanger");
fclose(stream);
close(fd);
return SR_ERR_SYS;
}
@@ -105,7 +104,6 @@ static int ly_add_yanger_data(const struct ly_ctx *ctx, struct lyd_node **parent
if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
ERROR("Error, unable reset stream (seek)");
fclose(stream);
close(fd);
return SR_ERR_SYS;
}
@@ -114,7 +112,7 @@ static int ly_add_yanger_data(const struct ly_ctx *ctx, struct lyd_node **parent
ERROR("Error, parsing yanger data (%d)", err);
fclose(stream);
close(fd);
/* Note: fclose() already closes the underlying fd from fdopen() */
return err;
}