From 0136339dced7e5c611703b91b22895bee7f64afa Mon Sep 17 00:00:00 2001 From: Kyotaro Horiguchi Date: Thu, 13 Feb 2020 14:27:41 +0900 Subject: [PATCH] Do null-check of error_context_stack before use The variable is accessed without null checking when planner is called in the context of pl/pgsql. Fix it. Back-patched up to pg_hint_plan94. Reporter: egashira-yusuke Issue: https://github.com/ossc-db/pg_hint_plan/issues/42 Original-Author: sun-wei <30999182+Dagouhan@users.noreply.github.com> Original-patch: https://github.com/ossc-db/pg_hint_plan/pull/45/commits/8fe092ef73a9af6cfb41e20717d7cb35aa74fce2 --- pg_hint_plan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pg_hint_plan.c b/pg_hint_plan.c index 9805dd6..a9075f4 100644 --- a/pg_hint_plan.c +++ b/pg_hint_plan.c @@ -3010,7 +3010,8 @@ pg_hint_plan_planner(Query *parse, int cursorOptions, ParamListInfo boundParams) * Support for nested plpgsql functions. This is quite ugly but this is the * only point I could find where I can get the query string. */ - if (plpgsql_recurse_level > 0) + if (plpgsql_recurse_level > 0 && + error_context_stack && error_context_stack->arg) { MemoryContext oldcontext; -- 2.11.0