[recipes] Avoid a crash in the recipe importer
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Avoid a crash in the recipe importer
- Date: Tue, 16 May 2017 12:11:42 +0000 (UTC)
commit 7504a0f93bdbe39eeea2dab3e5c18cc1502d129f
Author: Matthias Clasen <mclasen redhat com>
Date: Tue May 16 08:10:44 2017 -0400
Avoid a crash in the recipe importer
When no chef information is provided, we should show
an error right away instead of crashing later.
src/gr-recipe-importer.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/gr-recipe-importer.c b/src/gr-recipe-importer.c
index e952a3f..5e127c7 100644
--- a/src/gr-recipe-importer.c
+++ b/src/gr-recipe-importer.c
@@ -753,6 +753,7 @@ import_chefs (GrRecipeImporter *importer)
g_autoptr(GKeyFile) keyfile = NULL;
g_autofree char *path = NULL;
g_autoptr(GError) error = NULL;
+ gsize length;
g_assert (importer->chefs_keyfile == NULL);
g_assert (importer->chef_ids == NULL);
@@ -766,7 +767,14 @@ import_chefs (GrRecipeImporter *importer)
}
importer->chefs_keyfile = g_key_file_ref (keyfile);
- importer->chef_ids = g_key_file_get_groups (keyfile, NULL);
+ importer->chef_ids = g_key_file_get_groups (keyfile, &length);
+ if (length == 0) {
+ g_set_error (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ _("No chef information found"));
+ error_cb (importer->extractor, error, importer);
+ return FALSE;
+ }
+
return import_next_chef (importer);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]