]> 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:27 +0000 (00:37 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 30 Nov 2011 05:37:27 +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 428b4f9b6fd0a3a53d05db33830c887b294b401d..6b3ba2a31cab2d0c9cbb53a09b3638c4f37ab2d4 100644 (file)
@@ -337,8 +337,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 */
@@ -1112,8 +1114,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 */