Skip to content

Commit

Permalink
Ensure NULL-termination of string when unescaping single-quotes (#514)
Browse files Browse the repository at this point in the history
The for-loop is copying a string character by character and replacing `''` with `'`
by skipping a character if the current and next one are both `'`. When this
replacement doesn't occur then the target string will be filled completely
without a `\0' terminator at the end of the string.
  • Loading branch information
acritox authored Oct 30, 2023
1 parent c065c56 commit f92b03a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/bin/pgcopydb/ld_test_decoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ listToTuple(LogicalMessageTuple *tuple, TestDecodingColumns *cols, int count)
valueColumn->isQuoted = false;

int len = cur->valueLen;
valueColumn->val.str = (char *) calloc(len, sizeof(char));
valueColumn->val.str = (char *) calloc(len + 1, sizeof(char));

if (valueColumn->val.str == NULL)
{
Expand Down

0 comments on commit f92b03a

Please sign in to comment.