[gegl] Fix memory leak in rgbe_header_write.
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] Fix memory leak in rgbe_header_write.
- Date: Wed, 13 Jul 2022 20:10:19 +0000 (UTC)
commit b9b704e8b30e726c3ce3f1b88f7a2c70c8457b8a
Author: darnuria <darnuria darnuria eu>
Date: Wed Jul 13 20:10:18 2022 +0000
Fix memory leak in rgbe_header_write.
libs/rgbe/rgbe.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/libs/rgbe/rgbe.c b/libs/rgbe/rgbe.c
index 94f4fa94f..eedde2660 100644
--- a/libs/rgbe/rgbe.c
+++ b/libs/rgbe/rgbe.c
@@ -726,11 +726,15 @@ rgbe_write_line (FILE *f, gchar *line)
{
size_t written;
guint len = strlen (line);
+ gboolean has_endline = g_str_has_suffix (line, "\n");
+
+ if (!has_endline) {
+ g_free (line);
+ g_return_val_if_fail (has_endline, FALSE);
+ }
- g_return_val_if_fail (g_str_has_suffix (line, "\n"), FALSE);
written = fwrite (line, sizeof (line[0]), len, f);
g_free (line);
-
return written == len ? TRUE : FALSE;
}
@@ -827,7 +831,13 @@ rgbe_header_write (const rgbe_header *header,
"\n-Y %hu +X %hu\n",
header->y_axis.size,
header->x_axis.size);
- if (err < 0 || !rgbe_write_line (f, line))
+
+ if (err < 0) {
+ g_free(line);
+ goto cleanup;
+ }
+
+ if (!rgbe_write_line (f, line))
goto cleanup;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]