syntax: don't call getcwd() with a NULL pointer

Some platforms don't like that.
master
Benno Schulenberg 2016-06-04 12:02:49 +02:00
parent edf230b7df
commit ec7b20eec6
1 changed files with 5 additions and 2 deletions

View File

@ -189,11 +189,14 @@ void color_update(void)
/* If no syntax-override string was specified, or it didn't match, /* If no syntax-override string was specified, or it didn't match,
* try finding a syntax based on the filename (extension). */ * try finding a syntax based on the filename (extension). */
if (sint == NULL) { if (sint == NULL) {
char *currentdir = getcwd(NULL, PATH_MAX + 1); char *reserved = charalloc(PATH_MAX + 1);
char *currentdir = getcwd(reserved, PATH_MAX + 1);
char *joinednames = charalloc(PATH_MAX + 1); char *joinednames = charalloc(PATH_MAX + 1);
char *fullname = NULL; char *fullname = NULL;
if (currentdir != NULL) { if (currentdir == NULL)
free(reserved);
else {
/* Concatenate the current working directory with the /* Concatenate the current working directory with the
* specified filename, and canonicalize the result. */ * specified filename, and canonicalize the result. */
sprintf(joinednames, "%s/%s", currentdir, openfile->filename); sprintf(joinednames, "%s/%s", currentdir, openfile->filename);