Remove VLA from path_get_absolute_path

Remove the use of Variable Length Arrays in path_get_absolute_path(), and use
xmalloc/xfree instead.
This commit is contained in:
Rui Abreu Ferreira
2015-09-24 15:01:37 +01:00
parent ef5ee31452
commit e70d6283b6

View File

@@ -2083,7 +2083,7 @@ static int path_get_absolute_path(const char_u *fname, char_u *buf, int len, int
char_u *p;
*buf = NUL;
char relative_directory[len];
char *relative_directory = xmalloc(len);
char *end_of_path = (char *) fname;
// expand it if forced or not an absolute path
@@ -2105,9 +2105,11 @@ static int path_get_absolute_path(const char_u *fname, char_u *buf, int len, int
}
if (FAIL == path_full_dir_name(relative_directory, (char *) buf, len)) {
xfree(relative_directory);
return FAIL;
}
}
xfree(relative_directory);
return append_path((char *)buf, end_of_path, len);
}