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>
This commit is contained in:
parent
678bdfb0d0
commit
4d31709787
1 changed files with 3 additions and 2 deletions
|
@ -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,
|
/* since we know the length of the file string already,
|
||||||
* we can do malloc + memcpy rather than strdup */
|
* 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) {
|
if(files[files_count].name == NULL) {
|
||||||
ALLOC_FAIL(len);
|
ALLOC_FAIL(len);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
memcpy(files[files_count].name, line, len + 1);
|
memcpy(files[files_count].name, line, len);
|
||||||
files_count++;
|
files_count++;
|
||||||
}
|
}
|
||||||
/* attempt to hand back any memory we don't need */
|
/* attempt to hand back any memory we don't need */
|
||||||
|
|
Loading…
Add table
Reference in a new issue