Skip to content

Commit

Permalink
Fix crash when retrieving query hint
Browse files Browse the repository at this point in the history
This issue would be able to crash the server when for example setting
pg_hint_plan.parse_messages to 'error' in a session and trigger an error
via a hint that cannot be parsed.

Per issue #162.  This issue does not exist in 14 and newer branches
because get_current_hint_string() is much more careful with the handling
of pfree()'d current_hint_str there.

Reported-by: Pogosyan Vardan
Author: Sergei Glukhov
Backpatch-through: 12
  • Loading branch information
michaelpq committed Oct 11, 2023
1 parent 47f8231 commit 500ed88
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pg_hint_plan.c
Original file line number Diff line number Diff line change
Expand Up @@ -3015,7 +3015,10 @@ get_current_hint_string(ParseState *pstate, Query *query)
* use..
*/
if (current_hint_str)
{
pfree((void *)current_hint_str);
current_hint_str = NULL;
}

oldcontext = MemoryContextSwitchTo(TopMemoryContext);
current_hint_str = get_hints_from_comment(query_str);
Expand Down

0 comments on commit 500ed88

Please sign in to comment.