commit - ee7b409c1f35a02e204ac2e248414c19d73d6f41
commit + 9fad5d8c4a361d55ab50c7d41ddb1353d76c7302
blob - a8d58ed6d271776f1f9c6cfee7e9fa65c38bdf9b
blob + 50ef32d0850f5f4fc8b740e2895e1d5996b0df27
--- include/got_error.h
+++ include/got_error.h
#define GOT_ERR_NO_PATCH 149
#define GOT_ERR_HUNK_FAILED 150
#define GOT_ERR_PATCH_FAILED 151
+#define GOT_ERR_FILEIDX_DUP_ENTRY 152
struct got_error {
int code;
blob - 2411c3dde4d6b94f6ce98e88a3b798ee6b941285
blob + bbef129d76eb0c6b8a5a3712a558f9a05d225755
--- lib/error.c
+++ lib/error.c
{ GOT_ERR_NO_PATCH, "no patch found" },
{ GOT_ERR_HUNK_FAILED, "hunk failed to apply" },
{ GOT_ERR_PATCH_FAILED, "patch failed to apply" },
+ { GOT_ERR_FILEIDX_DUP_ENTRY, "duplicate file index entry" },
};
static struct got_custom_error {
blob - 90e142ecff05e48b31d5eacde6c048c20d94880e
blob + bbbf920360215773ac2f4f979efd72d2e5f2d742
--- lib/fileindex.c
+++ lib/fileindex.c
if (fileindex->nentries >= GOT_FILEIDX_MAX_ENTRIES)
return got_error(GOT_ERR_NO_SPACE);
- RB_INSERT(got_fileindex_tree, &fileindex->entries, ie);
+ if (RB_INSERT(got_fileindex_tree, &fileindex->entries, ie) != NULL)
+ return got_error_path(ie->path, GOT_ERR_FILEIDX_DUP_ENTRY);
+
fileindex->nentries++;
return NULL;
}
blob - 0756600c6c7bca294f7a50bfa99260c2474ee20e
blob + fcd77a0c22a86ae56b534d992bc21b9c76aa5354
--- lib/object_idset.c
+++ lib/object_idset.c
memcpy(&new->id, id, sizeof(new->id));
new->data = data;
- RB_INSERT(got_object_idset_tree, &set->entries, new);
+ if (RB_INSERT(got_object_idset_tree, &set->entries, new) != NULL) {
+ free(new);
+ return got_error(GOT_ERR_OBJ_EXISTS);
+ }
+
set->totelem++;
return NULL;
}