Fix accidentally-harmless thinko in psqlscan_test_variable().
This code was passing literal strings to psqlscan_emit, which is quite contrary to that function's specification: "If you pass it something that is not part of the yytext string, you are making a mistake". It accidentally worked anyway, even in non-safe_encoding mode. psqlscan_emit would compute a garbage "reference" pointer, but would never dereference that since the passed string is all-ASCII. So there's no live bug today, but that is a happenstance outcome of psqlscan_emit's current implementation. Let's make psqlscan_test_variable do what it's supposed to, namely append directly to the output buffer. This is just future-proofing against possible changes in psqlscan_emit, so I don't feel a need to back-patch.
This commit is contained in:
parent
0fcf02ad45
commit
2fd3e2fa5c
@ -1626,11 +1626,11 @@ psqlscan_test_variable(PsqlScanState state, const char *txt, int len)
|
|||||||
|
|
||||||
if (value != NULL)
|
if (value != NULL)
|
||||||
{
|
{
|
||||||
psqlscan_emit(state, "TRUE", 4);
|
appendPQExpBufferStr(state->output_buf, "TRUE");
|
||||||
free(value);
|
free(value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
psqlscan_emit(state, "FALSE", 5);
|
appendPQExpBufferStr(state->output_buf, "FALSE");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user