diff options
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/error.c')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/error.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/ecpglib/error.c b/src/interfaces/ecpg/ecpglib/error.c index 58024f47b0c..6d97f3f5734 100644 --- a/src/interfaces/ecpg/ecpglib/error.c +++ b/src/interfaces/ecpg/ecpglib/error.c @@ -14,6 +14,13 @@ ecpg_raise(int line, int code, const char *sqlstate, const char *str) { struct sqlca_t *sqlca = ECPGget_sqlca(); + if (sqlca == NULL) + { + ecpg_log("out of memory"); + ECPGfree_auto_mem(); + return; + } + sqlca->sqlcode = code; strncpy(sqlca->sqlstate, sqlstate, sizeof(sqlca->sqlstate)); @@ -293,6 +300,13 @@ ecpg_raise_backend(int line, PGresult *result, PGconn *conn, int compat) char *sqlstate; char *message; + if (sqlca == NULL) + { + ecpg_log("out of memory"); + ECPGfree_auto_mem(); + return; + } + if (result) { sqlstate = PQresultErrorField(result, PG_DIAG_SQLSTATE); @@ -401,6 +415,12 @@ sqlprint(void) { struct sqlca_t *sqlca = ECPGget_sqlca(); + if (sqlca == NULL) + { + ecpg_log("out of memory"); + return; + } + sqlca->sqlerrm.sqlerrmc[sqlca->sqlerrm.sqlerrml] = '\0'; fprintf(stderr, ecpg_gettext("SQL error: %s\n"), sqlca->sqlerrm.sqlerrmc); } |