[gnome-software/gnome-40: 4/7] gs-app: Fix generic setters to handle NULL arrays
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-40: 4/7] gs-app: Fix generic setters to handle NULL arrays
- Date: Mon, 3 May 2021 10:44:31 +0000 (UTC)
commit ff5d189202788ec84bf690b8ddb184240ae68e2d
Author: Philip Withnall <pwithnall endlessos org>
Date: Thu Apr 29 15:47:40 2021 +0100
gs-app: Fix generic setters to handle NULL arrays
The previous implementation of the functions didn’t handle `NULL`
arrays.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1227
lib/gs-app.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 6c6bb6fe6..efbc4756a 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -184,9 +184,11 @@ _g_set_ptr_array (GPtrArray **array_ptr, GPtrArray *new_array)
{
if (*array_ptr == new_array)
return FALSE;
+ if (new_array != NULL)
+ g_ptr_array_ref (new_array);
if (*array_ptr != NULL)
g_ptr_array_unref (*array_ptr);
- *array_ptr = g_ptr_array_ref (new_array);
+ *array_ptr = new_array;
return TRUE;
}
@@ -195,9 +197,11 @@ _g_set_array (GArray **array_ptr, GArray *new_array)
{
if (*array_ptr == new_array)
return FALSE;
+ if (new_array != NULL)
+ g_array_ref (new_array);
if (*array_ptr != NULL)
g_array_unref (*array_ptr);
- *array_ptr = g_array_ref (new_array);
+ *array_ptr = new_array;
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]