diff options
author | Michael Meskes <meskes@postgresql.org> | 2015-06-15 14:21:03 +0200 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2015-06-15 14:22:54 +0200 |
commit | 4130b2c1fdbe71838baba00312b8ca599b62f98d (patch) | |
tree | 9117ddddc3159d612507335a340d2ffdb8e2eab1 /src/interfaces/ecpg/ecpglib/descriptor.c | |
parent | 3e2a17eecc4ceb76ac40978a15b26e120dbd52a6 (diff) |
Check for out of memory when allocating sqlca.
Patch by Michael Paquier
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/descriptor.c')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/descriptor.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/interfaces/ecpg/ecpglib/descriptor.c b/src/interfaces/ecpg/ecpglib/descriptor.c index b2990cab289..ff011bd8165 100644 --- a/src/interfaces/ecpg/ecpglib/descriptor.c +++ b/src/interfaces/ecpg/ecpglib/descriptor.c @@ -93,6 +93,13 @@ ECPGget_desc_header(int lineno, const char *desc_name, int *count) PGresult *ECPGresult; struct sqlca_t *sqlca = ECPGget_sqlca(); + if (sqlca == NULL) + { + ecpg_raise(lineno, ECPG_OUT_OF_MEMORY, + ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL); + return false; + } + ecpg_init_sqlca(sqlca); ECPGresult = ecpg_result_by_descriptor(lineno, desc_name); if (!ECPGresult) @@ -245,6 +252,13 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...) struct variable data_var; struct sqlca_t *sqlca = ECPGget_sqlca(); + if (sqlca == NULL) + { + ecpg_raise(lineno, ECPG_OUT_OF_MEMORY, + ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL); + return false; + } + va_start(args, index); ecpg_init_sqlca(sqlca); ECPGresult = ecpg_result_by_descriptor(lineno, desc_name); @@ -703,6 +717,13 @@ ECPGdeallocate_desc(int line, const char *name) struct descriptor *prev; struct sqlca_t *sqlca = ECPGget_sqlca(); + if (sqlca == NULL) + { + ecpg_raise(line, ECPG_OUT_OF_MEMORY, + ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL); + return false; + } + ecpg_init_sqlca(sqlca); for (desc = get_descriptors(), prev = NULL; desc; prev = desc, desc = desc->next) { @@ -742,6 +763,13 @@ ECPGallocate_desc(int line, const char *name) struct descriptor *new; struct sqlca_t *sqlca = ECPGget_sqlca(); + if (sqlca == NULL) + { + ecpg_raise(line, ECPG_OUT_OF_MEMORY, + ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL); + return false; + } + ecpg_init_sqlca(sqlca); new = (struct descriptor *) ecpg_alloc(sizeof(struct descriptor), line); if (!new) |