common/dir: Avoid a potential NULL pointer dereference

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 <withnall@endlessm.com>
This commit is contained in:
Philip Withnall
2017-08-15 12:27:28 +01:00
parent ecbf42d7fa
commit c157719616

View File

@@ -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++)
{