diff options
author | Dan McGee <dan@archlinux.org> | 2012-04-30 06:23:54 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-04-30 06:23:54 +0200 |
commit | 4d3170978711a91f1afe8ffef9dad9c2bc60585d (patch) | |
tree | f9bbae7f7cbc63f783f4635b939b5cc5e59db761 | |
parent | 678bdfb0d079dba08bf1f4d34a93e5d36521c43d (diff) | |
download | pacman-4d3170978711a91f1afe8ffef9dad9c2bc60585d.tar.gz pacman-4d3170978711a91f1afe8ffef9dad9c2bc60585d.tar.xz |
be_local: use the right length value for filename in all cases
Increment the strlen() provided value by 1 for the NULL byte so we use
the right value in all three places we later reference it.
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | lib/libalpm/be_local.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index aab6718f..227bc9bc 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -677,12 +677,13 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq) } /* since we know the length of the file string already, * we can do malloc + memcpy rather than strdup */ - files[files_count].name = malloc(len + 1); + len += 1; + files[files_count].name = malloc(len); if(files[files_count].name == NULL) { ALLOC_FAIL(len); goto error; } - memcpy(files[files_count].name, line, len + 1); + memcpy(files[files_count].name, line, len); files_count++; } /* attempt to hand back any memory we don't need */ |