Skip to content

Commit

Permalink
Fix PgReThrowError to even make copy of const strings
Browse files Browse the repository at this point in the history
Task: BABEL-5157
Signed-off-by: Rishabh Tanwar <[email protected]>
  • Loading branch information
ritanwar authored and shardgupta committed Aug 13, 2024
1 parent 1e6271d commit ebd698f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/backend/utils/error/elog.c
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,14 @@ ReThrowError(ErrorData *edata)
memcpy(newedata, edata, sizeof(ErrorData));

/* Make copies of separately-allocated fields */
if (newedata->filename)
newedata->filename = pstrdup(newedata->filename);
if (newedata->funcname)
newedata->funcname = pstrdup(newedata->funcname);
if (newedata->domain)
newedata->domain = pstrdup(newedata->domain);
if (newedata->context_domain)
newedata->context_domain = pstrdup(newedata->context_domain);
if (newedata->message)
newedata->message = pstrdup(newedata->message);
if (newedata->detail)
Expand All @@ -1805,6 +1813,8 @@ ReThrowError(ErrorData *edata)
newedata->context = pstrdup(newedata->context);
if (newedata->backtrace)
newedata->backtrace = pstrdup(newedata->backtrace);
if (newedata->message_id)
newedata->message_id = pstrdup(newedata->message_id);
if (newedata->schema_name)
newedata->schema_name = pstrdup(newedata->schema_name);
if (newedata->table_name)
Expand Down

0 comments on commit ebd698f

Please sign in to comment.