Skip to content

Commit f97aaaa

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 1a44811 commit f97aaaa

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/backend/utils/error/elog.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,10 @@ errstart(int elevel, const char *filename, int lineno,
331331

332332
/* keep only base name, useful especially for vpath builds */
333333
slash = strrchr(filename, '/');
334-
edata->filename = slash ? slash + 1 : filename;
334+
if (slash)
335+
filename = slash + 1;
335336
}
337+
edata->filename = filename;
336338
edata->lineno = lineno;
337339
edata->funcname = funcname;
338340
/* Select default errcode based on elevel */
@@ -956,8 +958,10 @@ elog_start(const char *filename, int lineno, const char *funcname)
956958

957959
/* keep only base name, useful especially for vpath builds */
958960
slash = strrchr(filename, '/');
959-
edata->filename = slash ? slash + 1 : filename;
961+
if (slash)
962+
filename = slash + 1;
960963
}
964+
edata->filename = filename;
961965
edata->lineno = lineno;
962966
edata->funcname = funcname;
963967
/* errno is saved now so that error parameter eval can't change it */

0 commit comments

Comments
 (0)