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.
This commit is contained in:
Tom Lane 2011-11-30 00:37:38 -05:00
parent 1a44811775
commit f97aaaa06c
1 changed files with 6 additions and 2 deletions

View File

@ -331,8 +331,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;
/* Select default errcode based on elevel */
@ -956,8 +958,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 */