diff options
author | Emilio Pozuelo Monfort <pochu27@gmail.com> | 2010-12-06 15:41:21 +0100 |
---|---|---|
committer | Emilio Pozuelo Monfort <pochu27@gmail.com> | 2010-12-06 15:55:41 +0100 |
commit | 8ccbb77e4dc5852633fc6a656a5027852f6509fd (patch) | |
tree | 7d4befa6295f339170e845285a9c047922dc52c4 | |
parent | f306a03d96c7dca363d0b9049ba3954bdaf8c58f (diff) | |
download | telepathy-logger-8ccbb77e4dc5852633fc6a656a5027852f6509fd.tar.gz |
Check if we could open the log file before writing to it
https://bugs.freedesktop.org/show_bug.cgi?id=28795
-rw-r--r-- | 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; } |