Fixed buffer overrun issue detected by address sanitizer.

This commit is contained in:
Martin Lundh 2021-02-25 10:22:50 +01:00
parent 62bba78258
commit 3acd6a8b60

View File

@ -197,7 +197,7 @@ char *el_filename_complete(char *pathname, int *match)
if (ac == 1) { if (ac == 1) {
/* Exactly one match -- finish it off. */ /* Exactly one match -- finish it off. */
*match = 1; *match = 1;
j = strlen(av[0]) - len + 2; j = strlen(av[0]) - len + 1;
p = malloc(sizeof(char) * (j + 1)); p = malloc(sizeof(char) * (j + 1));
if (p) { if (p) {
memcpy(p, av[0] + len, j); memcpy(p, av[0] + len, j);