From 2209c0f8618bbed257975055e017efab139e3fa3 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Fri, 4 Apr 2014 19:07:37 -0400
Subject: [PATCH] Preserve errno across free().

Dept. of second thoughts: free() isn't guaranteed not to change errno.
Make sure we report the right error if getcwd() fails.
---
 src/port/path.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/port/path.c b/src/port/path.c
index 438b5296042..3484f2cb615 100644
--- a/src/port/path.c
+++ b/src/port/path.c
@@ -608,7 +608,10 @@ make_absolute_path(const char *path)
 			}
 			else
 			{
+				int			save_errno = errno;
+
 				free(buf);
+				errno = save_errno;
 #ifndef FRONTEND
 				elog(ERROR, "could not get current working directory: %m");
 #else
-- 
GitLab