[poppler] glib/poppler-attachment.cc glib/poppler-media.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Dec 7 00:25:48 UTC 2021
glib/poppler-attachment.cc | 1 +
glib/poppler-media.cc | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
New commits:
commit bb3f7206b3f1cde757384474414a91cdfd3bcb63
Author: Christian Persch <chpe at src.gnome.org>
Date: Fri Dec 3 13:03:30 2021 +0100
glib: Close file descriptors on error
When fdopen fails, the file descriptor must be closed manually so it
doesn't leak.
diff --git a/glib/poppler-attachment.cc b/glib/poppler-attachment.cc
index b44edded..2af11044 100644
--- a/glib/poppler-attachment.cc
+++ b/glib/poppler-attachment.cc
@@ -304,6 +304,7 @@ gboolean poppler_attachment_save_to_fd(PopplerAttachment *attachment, int fd, GE
if (f == nullptr) {
int errsv = errno;
g_set_error(error, G_FILE_ERROR, g_file_error_from_errno(errsv), _("Failed to open FD %d for writing: %s"), fd, g_strerror(errsv));
+ close(fd);
return FALSE;
}
diff --git a/glib/poppler-media.cc b/glib/poppler-media.cc
index 3966d6c0..9cc44594 100644
--- a/glib/poppler-media.cc
+++ b/glib/poppler-media.cc
@@ -303,10 +303,10 @@ gboolean poppler_media_save_to_fd(PopplerMedia *poppler_media, int fd, GError **
g_return_val_if_fail(poppler_media->stream.isStream(), FALSE);
f = fdopen(fd, "wb");
-
if (f == nullptr) {
int errsv = errno;
g_set_error(error, G_FILE_ERROR, g_file_error_from_errno(errsv), "Failed to open FD %d for writing: %s", fd, g_strerror(errsv));
+ close(fd);
return FALSE;
}
More information about the poppler
mailing list