context CHANGE return LY_EEXIST in case of setting duplicated searchdir
diff --git a/src/context.c b/src/context.c
index 1c82259..386ee05 100644
--- a/src/context.c
+++ b/src/context.c
@@ -87,9 +87,9 @@
                          LY_ESYS);
         /* avoid path duplication */
         for (u = 0; u < ctx->search_paths.count; ++u) {
-            if (!strcmp(new_dir, ctx->search_paths.objs[0])) {
+            if (!strcmp(new_dir, ctx->search_paths.objs[u])) {
                 free(new_dir);
-                return LY_SUCCESS;
+                return LY_EEXIST;
             }
         }
         if (ly_set_add(&ctx->search_paths, new_dir, LY_SET_OPT_USEASLIST) == -1) {
@@ -178,9 +178,17 @@
         for (dir = search_dir_list; (sep = strchr(dir, ':')) != NULL && rc == LY_SUCCESS; dir = sep + 1) {
             *sep = 0;
             rc = ly_ctx_set_searchdir(ctx, dir);
+            if (rc == LY_EEXIST) {
+                /* ignore duplication */
+                rc = LY_SUCCESS;
+            }
         }
         if (*dir && rc == LY_SUCCESS) {
             rc = ly_ctx_set_searchdir(ctx, dir);
+            if (rc == LY_EEXIST) {
+                /* ignore duplication */
+                rc = LY_SUCCESS;
+            }
         }
         free(search_dir_list);