]> granicus.if.org Git - postgresql/commitdiff
Tweak previous patch to ensure edata->filename always gets initialized.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 30 Nov 2011 05:37:14 +0000 (00:37 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 30 Nov 2011 05:37:14 +0000 (00:37 -0500)
On a platform that isn't supplying __FILE__, previous coding would either
crash or give a stale result for the filename string.  Not sure how likely
that is, but the original code catered for it, so let's keep doing so.

src/backend/utils/error/elog.c

index 8471d92f57fa86c657288fe01031ddb56d19231e..fee69dfc17225e69d3704a2af363f62c1a8508d6 100644 (file)
@@ -348,8 +348,10 @@ errstart(int elevel, const char *filename, int lineno,
 
                /* keep only base name, useful especially for vpath builds */
                slash = strrchr(filename, '/');
-               edata->filename = slash ? slash + 1 : filename;
+               if (slash)
+                       filename = slash + 1;
        }
+       edata->filename = filename;
        edata->lineno = lineno;
        edata->funcname = funcname;
        /* the default text domain is the backend's */
@@ -1154,8 +1156,10 @@ elog_start(const char *filename, int lineno, const char *funcname)
 
                /* keep only base name, useful especially for vpath builds */
                slash = strrchr(filename, '/');
-               edata->filename = slash ? slash + 1 : filename;
+               if (slash)
+                       filename = slash + 1;
        }
+       edata->filename = filename;
        edata->lineno = lineno;
        edata->funcname = funcname;
        /* errno is saved now so that error parameter eval can't change it */