]> granicus.if.org Git - postgresql/commitdiff
Preserve errno across free().
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 4 Apr 2014 23:07:37 +0000 (19:07 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 4 Apr 2014 23:07:37 +0000 (19:07 -0400)
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

index 438b52960423bfec077e78e7d80246fffa4899ac..3484f2cb6155fc7865adc4c3e4d807a661793ddc 100644 (file)
@@ -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