postgres.git / summary / log / commit / refs

commit    a87ebace190b16bbc6454bb93bae3356712aa3ca
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Wed Nov 30 05:37:06 2011 +0000
First released in: 9.2.0, 8.2.23, 8.3.17, 8.4.10, 9.0.6, 9.1.2

    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.


src/backend/utils/error/elog.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 0131c06ba4d..d8d059f11c9 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -349,8 +349,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 */ @@ -1155,8 +1157,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 */ [parent: dd136052bcc8]