diff options
author | Robert Haas <rhaas@postgresql.org> | 2013-12-02 10:40:33 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2013-12-02 10:42:01 -0500 |
commit | 9d140f7be2836e3baf6c9dc7989dea69ef693532 (patch) | |
tree | d7a7a7412deeb7a445a2390434f32bb77409c598 /src | |
parent | 3e3520cf7a70aa85f55a7be37924aaa1809a4be3 (diff) | |
download | postgresql-9d140f7be2836e3baf6c9dc7989dea69ef693532.tar.gz postgresql-9d140f7be2836e3baf6c9dc7989dea69ef693532.zip |
Avoid out-of-bounds read in errfinish if error_stack_depth < 0.
If errordata_stack_depth < 0, we won't find that out and correct the
problem until CHECK_STACK_DEPTH() is invoked. In the meantime,
elevel will be set based on an invalid read. This is probably
harmless in practice, but it seems cleaner this way.
Xi Wang
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/error/elog.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index e648792d22e..65eb3bd8dec 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -397,12 +397,13 @@ void errfinish(int dummy,...) { ErrorData *edata = &errordata[errordata_stack_depth]; - int elevel = edata->elevel; + int elevel; MemoryContext oldcontext; ErrorContextCallback *econtext; recursion_depth++; CHECK_STACK_DEPTH(); + elevel = edata->elevel; /* * Do processing in ErrorContext, which we hope has enough reserved space |