mirror of
https://github.com/zebrajr/postgres.git
synced 2025-12-06 12:20:15 +01:00
ecpg: check return value of replace_variables()
The function returns false if it fails to allocate memory, so make sure to check the return value in callsites. Author: Aleksander Alekseev <aleksander@tigerdata.com> Reviewed-by: Daniel Gustafsson <daniel@yesql.se> Discussion: https://postgr.es/m/CAJ7c6TNPrU8ZxgdfN3PyGY1tzo0bgszx+KkqW0Z7zt3heyC1GQ@mail.gmail.com
This commit is contained in:
parent
6aa184c80f
commit
0d82163958
|
|
@ -200,7 +200,13 @@ prepare_common(int lineno, struct connection *con, const char *name, const char
|
||||||
stmt->inlist = stmt->outlist = NULL;
|
stmt->inlist = stmt->outlist = NULL;
|
||||||
|
|
||||||
/* if we have C variables in our statement replace them with '?' */
|
/* if we have C variables in our statement replace them with '?' */
|
||||||
replace_variables(&(stmt->command), lineno);
|
if (!replace_variables(&(stmt->command), lineno))
|
||||||
|
{
|
||||||
|
ecpg_free(stmt->command);
|
||||||
|
ecpg_free(stmt);
|
||||||
|
ecpg_free(this);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* add prepared statement to our list */
|
/* add prepared statement to our list */
|
||||||
this->name = ecpg_strdup(name, lineno, NULL);
|
this->name = ecpg_strdup(name, lineno, NULL);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user