psqlodbc.git / summary / log / commit / refs
commit 6ffd4f2a68cd043127a2c32e620dde35f447ab33
Author: Hiroshi Inoue <h-inoue@dream.email.ne.jp>
Date: Fri Aug 25 02:56:56 2017 +0000
Fix bug that calls strdup() for NULL pointers.
Per report from Ding, Haiqiang.
connection.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/connection.c b/connection.c
index dbe703b4..3df8711a 100644
--- a/connection.c
+++ b/connection.c
@@ -1061,6 +1061,7 @@ CC_connect(ConnectionClass *self, char *salt_para)
ConnInfo *ci = &(self->connInfo);
CSTR func = "CC_connect";
char ret, *saverr = NULL, retsend;
+ const char *errmsg = NULL;
MYLOG(0, "%s: entering...\n", func);
@@ -1086,8 +1087,9 @@ CC_connect(ConnectionClass *self, char *salt_para)
/* Per Datasource settings */
retsend = CC_send_settings(self, GET_NAME(self->connInfo.conn_settings));
- if (CC_get_errornumber(self) > 0)
- saverr = strdup(CC_get_errormsg(self));
+ if (CC_get_errornumber(self) > 0 &&
+ NULL != (errmsg = CC_get_errormsg(self)))
+ saverr = strdup(errmsg);
CC_clear_error(self); /* clear any error */
CC_lookup_lo(self); /* a hack to get the oid of
our large object oid type */
[parent: 833dbb0a409c]