Skip to content

Commit e8d14ce

Browse files
committed
bin/xbps-rindex: fix memory leak in --clean
1 parent 4400cef commit e8d14ce

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

bin/xbps-rindex/index-clean.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,24 @@ cleanup_repo(struct xbps_handle *xhp, const char *repodir, struct xbps_repo *rep
128128
xbps_object_release(allkeys);
129129

130130
if (xbps_dictionary_equals(index, repo->index) &&
131-
xbps_dictionary_equals(stage, repo->stage))
131+
xbps_dictionary_equals(stage, repo->stage)) {
132+
xbps_object_release(index);
133+
xbps_object_release(stage);
132134
return 0;
135+
}
133136

134137
r = repodata_flush(repodir, repoarch, index, stage, repo->idxmeta, compression);
135138
if (r < 0) {
136139
xbps_error_printf("failed to write repodata: %s\n", strerror(-r));
140+
xbps_object_release(index);
141+
xbps_object_release(stage);
137142
return r;
138143
}
139144
printf("stage: %u packages registered.\n", xbps_dictionary_count(stage));
140145
printf("index: %u packages registered.\n", xbps_dictionary_count(index));
141-
return r;
146+
xbps_object_release(index);
147+
xbps_object_release(stage);
148+
return 0;
142149
}
143150

144151
/*
@@ -167,7 +174,7 @@ index_clean(struct xbps_handle *xhp, const char *repodir, const bool hashcheck,
167174
return 0;
168175
}
169176
xbps_error_printf("cannot read repository data: %s\n",
170-
strerror(errno));
177+
strerror(-r));
171178
xbps_repo_unlock(repodir, arch, lockfd);
172179
return EXIT_FAILURE;
173180
}

0 commit comments

Comments
 (0)