From 8ccbb77e4dc5852633fc6a656a5027852f6509fd Mon Sep 17 00:00:00 2001 From: Emilio Pozuelo Monfort Date: Mon, 6 Dec 2010 15:41:21 +0100 Subject: [PATCH] Check if we could open the log file before writing to it https://bugs.freedesktop.org/show_bug.cgi?id=28795 --- telepathy-logger/log-store-xml.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/telepathy-logger/log-store-xml.c b/telepathy-logger/log-store-xml.c index 0fdaa84..d5f3744 100644 --- a/telepathy-logger/log-store-xml.c +++ b/telepathy-logger/log-store-xml.c @@ -379,6 +379,7 @@ _log_store_xml_write_to_store (TplLogStoreXml *self, FILE *file; gchar *filename; gchar *basedir; + gboolean ret = TRUE; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (TPL_IS_LOG_STORE_XML (self), FALSE); @@ -410,12 +411,21 @@ _log_store_xml_write_to_store (TplLogStoreXml *self, if (file != NULL) fseek (file, -strlen (LOG_FOOTER), SEEK_END); } + if (file == NULL) + { + g_set_error (error, TPL_LOG_STORE_ERROR, + TPL_LOG_STORE_ERROR_FAILED, + "Couldn't open log file: %s", filename); + ret = FALSE; + goto out; + } g_fprintf (file, "%s", entry); - /*DEBUG ("%s: written: %s", filename, entry);*/ + DEBUG ("%s: written: %s", filename, entry); fclose (file); + out: g_free (filename); - return TRUE; + return ret; } -- 1.7.2.3