return error from search_packidx() if dup_packidx() fails
diff --git a/lib/pack.c b/lib/pack.c
index f6ad8c9..b0e1612 100644
--- a/lib/pack.c
+++ b/lib/pack.c
@@ -407,7 +407,7 @@ search_packidx(struct got_packidx_v2_hdr **packidx, int *idx,
if (*idx != -1) {
*packidx = dup_packidx(repo->packidx_cache[i]);
if (*packidx == NULL)
- *idx = -1;
+ return got_error(GOT_ERR_NO_MEM);
return NULL;
}
}