Blame SOURCES/0006-merge_ent_array_duplicates-Only-use-values-if-valid.patch

cd37fb
From 8da7fc83aa3e9fd868c6a8da9261b72dae7d29e7 Mon Sep 17 00:00:00 2001
cd37fb
From: Jakub Hrozek <jakub.hrozek@posteo.se>
cd37fb
Date: Wed, 26 Sep 2018 21:38:02 +0200
cd37fb
Subject: [PATCH 6/7] merge_ent_array_duplicates: Only use values if valid
cd37fb
cd37fb
Merges:
cd37fb
https://pagure.io/libuser/issue/22
cd37fb
cd37fb
Don't attempt to dereference a NULL pointer
cd37fb
---
cd37fb
 lib/user.c | 22 ++++++++++++++--------
cd37fb
 1 file changed, 14 insertions(+), 8 deletions(-)
cd37fb
cd37fb
diff --git a/lib/user.c b/lib/user.c
cd37fb
index ad2bb099c7d12bd91188e69f188c64953b1d9748..2500565a544bb33a5e08d9807a794a42c819a2d2 100644
cd37fb
--- a/lib/user.c
cd37fb
+++ b/lib/user.c
cd37fb
@@ -691,10 +691,13 @@ merge_ent_array_duplicates(GPtrArray *array)
cd37fb
 			while (attributes != NULL) {
cd37fb
 				attr = (const char *)attributes->data;
cd37fb
 				values = lu_ent_get_current(current, attr);
cd37fb
-				for (j = 0; j < values->n_values; j++) {
cd37fb
-					value = g_value_array_get_nth(values,
cd37fb
-								      j);
cd37fb
-					lu_ent_add_current(saved, attr, value);
cd37fb
+				if (values != NULL) {
cd37fb
+					for (j = 0; j < values->n_values; j++) {
cd37fb
+						value = g_value_array_get_nth(
cd37fb
+									values,
cd37fb
+									j);
cd37fb
+						lu_ent_add_current(saved, attr, value);
cd37fb
+					}
cd37fb
 				}
cd37fb
 				attributes = g_list_next(attributes);
cd37fb
 			}
cd37fb
@@ -705,10 +708,13 @@ merge_ent_array_duplicates(GPtrArray *array)
cd37fb
 			while (attributes != NULL) {
cd37fb
 				attr = (const char *)attributes->data;
cd37fb
 				values = lu_ent_get(current, attr);
cd37fb
-				for (j = 0; j < values->n_values; j++) {
cd37fb
-					value = g_value_array_get_nth(values,
cd37fb
-								      j);
cd37fb
-					lu_ent_add(saved, attr, value);
cd37fb
+				if (values != NULL) {
cd37fb
+					for (j = 0; j < values->n_values; j++) {
cd37fb
+						value = g_value_array_get_nth(
cd37fb
+									values,
cd37fb
+									j);
cd37fb
+						lu_ent_add(saved, attr, value);
cd37fb
+					}
cd37fb
 				}
cd37fb
 				attributes = g_list_next(attributes);
cd37fb
 			}
cd37fb
-- 
cd37fb
2.14.4
cd37fb