From ec7b20eec67587ffb3ea5834843b386294d32248 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 4 Jun 2016 12:02:49 +0200
Subject: [PATCH] syntax: don't call getcwd() with a NULL pointer

Some platforms don't like that.
---
 src/color.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/color.c b/src/color.c
index 75e92432..39355ca7 100644
--- a/src/color.c
+++ b/src/color.c
@@ -189,11 +189,14 @@ void color_update(void)
     /* If no syntax-override string was specified, or it didn't match,
      * try finding a syntax based on the filename (extension). */
     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 *fullname = NULL;
 
-	if (currentdir != NULL) {
+	if (currentdir == NULL)
+	    free(reserved);
+	else {
 	    /* Concatenate the current working directory with the
 	     * specified filename, and canonicalize the result. */
 	    sprintf(joinednames, "%s/%s", currentdir, openfile->filename);
-- 
GitLab