[gcab] trivial: Return an error when adding a duplicate folder to a cabinet
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcab] trivial: Return an error when adding a duplicate folder to a cabinet
- Date: Tue, 12 Dec 2017 21:39:28 +0000 (UTC)
commit 89bb0054be0ad0a1743210cc4b479056429f227e
Author: Richard Hughes <richard hughsie com>
Date: Tue Dec 12 20:45:45 2017 +0000
trivial: Return an error when adding a duplicate folder to a cabinet
libgcab/gcab-cabinet.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/libgcab/gcab-cabinet.c b/libgcab/gcab-cabinet.c
index 771c3d1..10123d5 100644
--- a/libgcab/gcab-cabinet.c
+++ b/libgcab/gcab-cabinet.c
@@ -171,6 +171,15 @@ gcab_cabinet_add_folder (GCabCabinet *self,
g_return_val_if_fail (GCAB_IS_FOLDER (folder), FALSE);
g_return_val_if_fail (!error || *error == NULL, FALSE);
+ for (guint i = 0; i < self->folders->len; i++) {
+ GCabFolder *folder_tmp = g_ptr_array_index (self->folders, i);
+ if (folder_tmp == folder) {
+ g_set_error (error, GCAB_ERROR, GCAB_ERROR_FORMAT,
+ "Folder has already been added");
+ return FALSE;
+ }
+ }
+
g_ptr_array_add (self->folders, g_object_ref (folder));
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]