Skip to content

Commit ef4db25

Browse files
ocean-dot-lipolardb-bot[bot]
authored andcommitted
[Bug] fix log buffer inital issue
In exec_execute_message(), we should initalize the log buffer at outermost layer. If not, crash may happen when trying to accessing its data member. This patch fixes the issue.
1 parent 871ea83 commit ef4db25

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/backend/tcop/postgres.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2354,13 +2354,17 @@ exec_execute_message(const char *portal_name, long max_rows)
23542354
pq_putemptymessage('s');
23552355
}
23562356

2357+
buf.data = NULL;
2358+
23572359
if (to_log)
23582360
{
23592361
/* POLAR: get errmsg params string, we must free it in the last */
23602362
// It needs to malloc and free twice, not so efficiency.
23612363
params_string = polar_get_errmsg_params(portalParams);
23622364

2365+
/* POLAR: inital buf used by logging info. */
23632366
initStringInfo(&buf);
2367+
23642368
if (polar_enable_log_search_path)
23652369
appendStringInfo(&buf, "/*polardb %s polardb*/ ", namespace_search_path);
23662370

@@ -2491,7 +2495,7 @@ exec_execute_message(const char *portal_name, long max_rows)
24912495
pfree(params_string);
24922496
/* POLAR end */
24932497

2494-
if (buf.data)
2498+
if (to_log && buf.data)
24952499
pfree(buf.data);
24962500

24972501
if (save_log_statement_stats)

0 commit comments

Comments
 (0)