Plug various minor memory leaks
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
c8417f3386
commit
964640fbfc
5 changed files with 8 additions and 3 deletions
|
@ -943,6 +943,7 @@ int _alpm_local_db_remove(alpm_db_t *db, alpm_pkg_t *info)
|
||||||
|
|
||||||
dirp = opendir(pkgpath);
|
dirp = opendir(pkgpath);
|
||||||
if(!dirp) {
|
if(!dirp) {
|
||||||
|
free(pkgpath);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* go through the local DB entry, removing the files within, which we know
|
/* go through the local DB entry, removing the files within, which we know
|
||||||
|
|
|
@ -358,6 +358,7 @@ static FILE *create_tempfile(struct dload_payload *payload, const char *localpat
|
||||||
CLOSE(fd);
|
CLOSE(fd);
|
||||||
_alpm_log(payload->handle, ALPM_LOG_ERROR,
|
_alpm_log(payload->handle, ALPM_LOG_ERROR,
|
||||||
_("failed to create temporary file for download\n"));
|
_("failed to create temporary file for download\n"));
|
||||||
|
free(randpath);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* fp now points to our alpmtmp.XXXXXX */
|
/* fp now points to our alpmtmp.XXXXXX */
|
||||||
|
|
|
@ -698,7 +698,7 @@ static int apply_deltas(alpm_handle_t *handle)
|
||||||
snprintf(from, len, "%s/%s", cachedir, d->from);
|
snprintf(from, len, "%s/%s", cachedir, d->from);
|
||||||
}
|
}
|
||||||
len = strlen(cachedir) + strlen(d->to) + 2;
|
len = strlen(cachedir) + strlen(d->to) + 2;
|
||||||
MALLOC(to, len, RET_ERR(handle, ALPM_ERR_MEMORY, 1));
|
MALLOC(to, len, free(from); RET_ERR(handle, ALPM_ERR_MEMORY, 1));
|
||||||
snprintf(to, len, "%s/%s", cachedir, d->to);
|
snprintf(to, len, "%s/%s", cachedir, d->to);
|
||||||
|
|
||||||
/* build the patch command */
|
/* build the patch command */
|
||||||
|
|
|
@ -812,10 +812,11 @@ int main(int argc, char *argv[])
|
||||||
/* we support reading targets from stdin if a cmdline parameter is '-' */
|
/* we support reading targets from stdin if a cmdline parameter is '-' */
|
||||||
if(!isatty(fileno(stdin)) && alpm_list_find_str(pm_targets, "-")) {
|
if(!isatty(fileno(stdin)) && alpm_list_find_str(pm_targets, "-")) {
|
||||||
size_t current_size = PATH_MAX;
|
size_t current_size = PATH_MAX;
|
||||||
char *line = malloc(current_size);
|
char *vdata, *line = malloc(current_size);
|
||||||
|
|
||||||
/* remove the '-' from the list */
|
/* remove the '-' from the list */
|
||||||
pm_targets = alpm_list_remove_str(pm_targets, "-", NULL);
|
pm_targets = alpm_list_remove_str(pm_targets, "-", &vdata);
|
||||||
|
free(vdata);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while((line[i] = (char)fgetc(stdin)) != EOF) {
|
while((line[i] = (char)fgetc(stdin)) != EOF) {
|
||||||
|
|
|
@ -560,6 +560,8 @@ static size_t table_calc_widths(const alpm_list_t *header,
|
||||||
colwidths = malloc(totalcols * sizeof(size_t));
|
colwidths = malloc(totalcols * sizeof(size_t));
|
||||||
coldata = calloc(totalcols, sizeof(int));
|
coldata = calloc(totalcols, sizeof(int));
|
||||||
if(!colwidths || !coldata) {
|
if(!colwidths || !coldata) {
|
||||||
|
free(colwidths);
|
||||||
|
free(coldata);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* header determines column count and initial values of longest_strs */
|
/* header determines column count and initial values of longest_strs */
|
||||||
|
|
Loading…
Add table
Reference in a new issue