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:
Andrew Gregory 2012-11-24 13:15:04 -05:00 committed by Allan McRae
parent c8417f3386
commit 964640fbfc
5 changed files with 8 additions and 3 deletions

View File

@ -943,6 +943,7 @@ int _alpm_local_db_remove(alpm_db_t *db, alpm_pkg_t *info)
dirp = opendir(pkgpath);
if(!dirp) {
free(pkgpath);
return -1;
}
/* go through the local DB entry, removing the files within, which we know

View File

@ -358,6 +358,7 @@ static FILE *create_tempfile(struct dload_payload *payload, const char *localpat
CLOSE(fd);
_alpm_log(payload->handle, ALPM_LOG_ERROR,
_("failed to create temporary file for download\n"));
free(randpath);
return NULL;
}
/* fp now points to our alpmtmp.XXXXXX */

View File

@ -698,7 +698,7 @@ static int apply_deltas(alpm_handle_t *handle)
snprintf(from, len, "%s/%s", cachedir, d->from);
}
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);
/* build the patch command */

View File

@ -812,10 +812,11 @@ int main(int argc, char *argv[])
/* we support reading targets from stdin if a cmdline parameter is '-' */
if(!isatty(fileno(stdin)) && alpm_list_find_str(pm_targets, "-")) {
size_t current_size = PATH_MAX;
char *line = malloc(current_size);
char *vdata, *line = malloc(current_size);
/* 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;
while((line[i] = (char)fgetc(stdin)) != EOF) {

View File

@ -560,6 +560,8 @@ static size_t table_calc_widths(const alpm_list_t *header,
colwidths = malloc(totalcols * sizeof(size_t));
coldata = calloc(totalcols, sizeof(int));
if(!colwidths || !coldata) {
free(colwidths);
free(coldata);
return 0;
}
/* header determines column count and initial values of longest_strs */