diff options
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/connect.c')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/connect.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c index d255c5d8f88..f3571becadb 100644 --- a/src/interfaces/ecpg/ecpglib/connect.c +++ b/src/interfaces/ecpg/ecpglib/connect.c @@ -216,6 +216,12 @@ ECPGnoticeReceiver(void *arg, const PGresult *result) struct sqlca_t *sqlca = ECPGget_sqlca(); int sqlcode; + if (sqlca == NULL) + { + ecpg_log("out of memory"); + return; + } + (void) arg; /* keep the compiler quiet */ if (sqlstate == NULL) sqlstate = ECPG_SQLSTATE_ECPG_INTERNAL_ERROR; @@ -277,6 +283,14 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p *options = NULL, *connect_string = NULL; + if (sqlca == NULL) + { + ecpg_raise(lineno, ECPG_OUT_OF_MEMORY, + ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL); + ecpg_free(dbname); + return false; + } + ecpg_init_sqlca(sqlca); /* @@ -556,6 +570,13 @@ ECPGdisconnect(int lineno, const char *connection_name) struct sqlca_t *sqlca = ECPGget_sqlca(); struct connection *con; + if (sqlca == NULL) + { + ecpg_raise(lineno, ECPG_OUT_OF_MEMORY, + ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL); + return (false); + } + #ifdef ENABLE_THREAD_SAFETY pthread_mutex_lock(&connections_mutex); #endif |