aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/lib/ecpglib.c
diff options
context:
space:
mode:
authorThomas G. Lockhart <lockhart@fourpalms.org>1998-10-03 02:33:51 +0000
committerThomas G. Lockhart <lockhart@fourpalms.org>1998-10-03 02:33:51 +0000
commit607cd930d5095f914aa6d3f23d29a41cedcf92af (patch)
tree71861c03759fd973ee46bc3d20accf2dfaf17938 /src/interfaces/ecpg/lib/ecpglib.c
parentcbfc9ec6ca31c6106707153dc45840dde1113220 (diff)
downloadpostgresql-607cd930d5095f914aa6d3f23d29a41cedcf92af.tar.gz
postgresql-607cd930d5095f914aa6d3f23d29a41cedcf92af.zip
Changes from Michael Meskes:
Check strdup calls for out of memory. Set library version to 2.6.2 Synced preproc.y and keywords.c with gram.y and keywords.c yet again. Set version to 2.4.3
Diffstat (limited to 'src/interfaces/ecpg/lib/ecpglib.c')
-rw-r--r--src/interfaces/ecpg/lib/ecpglib.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/interfaces/ecpg/lib/ecpglib.c b/src/interfaces/ecpg/lib/ecpglib.c
index 4b7ed87c1ff..f982d5103cb 100644
--- a/src/interfaces/ecpg/lib/ecpglib.c
+++ b/src/interfaces/ecpg/lib/ecpglib.c
@@ -148,6 +148,22 @@ ecpg_alloc(long size, int lineno)
return (new);
}
+static char *
+ecpg_strdup(const char *string, int lineno)
+{
+ char *new = strdup(string);
+
+ if (!new)
+ {
+ ECPGfinish(actual_connection);
+ ECPGlog("out of memory\n");
+ register_error(ECPG_OUT_OF_MEMORY, "out of memory in line %d", lineno);
+ return NULL;
+ }
+
+ return (new);
+}
+
/* This function returns a newly malloced string that has the ' and \
in the argument quoted with \.
*/
@@ -246,7 +262,7 @@ ECPGexecute(struct statement * stmt)
memcpy((char *) &sqlca, (char *) &sqlca_init, sizeof(sqlca));
- copiedquery = strdup(stmt->command);
+ copiedquery = ecpg_strdup(stmt->command, stmt->lineno);
/*
* Now, if the type is one of the fill in types then we take the
@@ -914,9 +930,9 @@ ECPGconnect(int lineno, const char *dbname, const char *user, const char *passwd
/* add connection to our list */
if (connection_name != NULL)
- this->name = strdup(connection_name);
+ this->name = ecpg_strdup(connection_name, lineno);
else
- this->name = strdup(dbname);
+ this->name = ecpg_strdup(dbname, lineno);
if (all_connections == NULL)
this->next = NULL;