From a241fcf6f228257e8fae8b3e2525d6de7eee23aa Mon Sep 17 00:00:00 2001 From: Eric van Gyzen Date: Thu, 27 Jul 2023 16:00:15 -0500 Subject: [PATCH] Add error handling in MsgLoadCatalog g_io_channel_read_line returns an error status in addition to setting its GError output parameter. Check both for errors. --- open-vm-tools/libvmtools/i18n.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/open-vm-tools/libvmtools/i18n.c b/open-vm-tools/libvmtools/i18n.c index 3085f72d7..69a92f4aa 100644 --- a/open-vm-tools/libvmtools/i18n.c +++ b/open-vm-tools/libvmtools/i18n.c @@ -484,7 +484,7 @@ MsgLoadCatalog(const char *path) gboolean eof = FALSE; char *name = NULL; char *value = NULL; - gchar *line; + gchar *line = NULL; /* Read the next key / value pair. */ for (;;) { @@ -493,12 +493,13 @@ MsgLoadCatalog(const char *path) gsize term; char *unused = NULL; gboolean cont = FALSE; + GIOStatus status; - g_io_channel_read_line(stream, &line, &len, &term, &err); + status = g_io_channel_read_line(stream, &line, &len, &term, &err); - if (err != NULL) { + if (status == G_IO_STATUS_ERROR || err != NULL) { g_warning("Unable to read a line from '%s': %s\n", - path, err->message); + path, err ? err->message : "G_IO_STATUS_ERROR"); g_clear_error(&err); error = TRUE; g_free(line);