From c157719616b7ea2540e5a2e2a2ed63e34f74866a Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 15 Aug 2017 12:27:28 +0100 Subject: [PATCH] common/dir: Avoid a potential NULL pointer dereference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Everywhere else that index->manifests is used, it’s checked for being NULL beforehand, which probably means that, sometimes, it might be NULL. Let’s check that here too. Coverity issue: 1452432 Signed-off-by: Philip Withnall --- common/flatpak-dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index 74ae66e9..8701971a 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -6612,7 +6612,8 @@ flatpak_dir_remote_make_oci_summary (FlatpakDir *self, additional_metadata_builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}")); /* The summary has to be sorted by ref, so pre-sort the manifests */ - qsort (index->manifests, flatpak_oci_index_get_n_manifests (index), sizeof (FlatpakOciManifestDescriptor *), compare_mdp); + if (index->manifests != NULL) + qsort (index->manifests, flatpak_oci_index_get_n_manifests (index), sizeof (FlatpakOciManifestDescriptor *), compare_mdp); for (i = 0; index->manifests != NULL && index->manifests[i] != NULL; i++) {