[gnome-logs] Fix crash while exporting blank journal
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-logs] Fix crash while exporting blank journal
- Date: Tue, 27 Mar 2018 15:11:09 +0000 (UTC)
commit 8a639f3074100378d5cc344bf124a5fac2632240
Author: H00ly666 <hecai4237 gmail com>
Date: Tue Mar 27 22:42:37 2018 +0800
Fix crash while exporting blank journal
gnome-logs crashes when exporting a blank journal.
This patch add a check against NULL pointers.
Closes #794724.
src/gl-window.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/gl-window.c b/src/gl-window.c
index a06f1d4..c604285 100644
--- a/src/gl-window.c
+++ b/src/gl-window.c
@@ -144,8 +144,14 @@ on_export (GSimpleAction *action,
g_clear_error (&error);
}
- g_output_stream_write (G_OUTPUT_STREAM (file_ostream), file_content,
- strlen (file_content), NULL, &error);
+ /* Check against NULL pointer to avoid a crash when exporting and there
+ * are no log entries. */
+ if (file_content != NULL)
+ {
+ g_output_stream_write (G_OUTPUT_STREAM (file_ostream), file_content,
+ strlen (file_content), NULL, &error);
+ }
+
if (error != NULL)
{
have_error = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]