commit - bb6672b6aba1cb45a10d52bec828e68379e9ad61
commit + a7472cb3288c2323830462f53706b013f33c444e
blob - 15a27715685e7d137844ebe2be87a33d550d6f96
blob + 8ae16da40c07f4dcb3133f9ff08328a10605722b
--- 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 - 19d6e558696c99c50807ee4f730af001911d1f1f
blob + 29541c0234b7f96a4638157fdd9017888571a76c
--- 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 - 6ea3deaf8e0753eaf31a2c0f81af1a25b313be30
blob + b05a8137d02606a3c4fee8f04809b0ac5cd71e8d
--- 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 - 37ea8e262784f9521e53f7db7f9ff11232dce3d6
blob + 06f7347e22beeabe835c116ac99d59e61f87ea68
--- 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;
}