Skip to content

Commit b06c6f5

Browse files
committed
Tweak previous patch to ensure edata->filename always gets initialized.
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.
1 parent 75b6183 commit b06c6f5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/backend/utils/error/elog.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,10 @@ errstart(int elevel, const char *filename, int lineno,
341341

342342
/* keep only base name, useful especially for vpath builds */
343343
slash = strrchr(filename, '/');
344-
edata->filename = slash ? slash + 1 : filename;
344+
if (slash)
345+
filename = slash + 1;
345346
}
347+
edata->filename = filename;
346348
edata->lineno = lineno;
347349
edata->funcname = funcname;
348350
/* the default text domain is the backend's */
@@ -1116,8 +1118,10 @@ elog_start(const char *filename, int lineno, const char *funcname)
11161118

11171119
/* keep only base name, useful especially for vpath builds */
11181120
slash = strrchr(filename, '/');
1119-
edata->filename = slash ? slash + 1 : filename;
1121+
if (slash)
1122+
filename = slash + 1;
11201123
}
1124+
edata->filename = filename;
11211125
edata->lineno = lineno;
11221126
edata->funcname = funcname;
11231127
/* errno is saved now so that error parameter eval can't change it */

0 commit comments

Comments
 (0)