changeset 86173:0606e4aac08a

Only malloc a new buffer if a positive length is specified.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Wed, 27 Jul 2022 18:17:26 +0200
parents 8fff25e863e6
children 617c6d0c2acb
files clients/odbc/driver/SQLGetConnectAttr.c
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/clients/odbc/driver/SQLGetConnectAttr.c
+++ b/clients/odbc/driver/SQLGetConnectAttr.c
@@ -84,7 +84,7 @@ MNDBGetConnectAttr(ODBCDbc *dbc,
 		break;
 	case SQL_ATTR_CURRENT_CATALOG:		/* SQLCHAR* */
 		/* SQL_CURRENT_QUALIFIER */
-		/* MonetDB does NOT support SQL catalog concept, return empty string */
+		/* MonetDB does NOT support SQL catalog qualifier, return empty string */
 		if (BufferLength <= 0) {
 			/* Invalid string or buffer length */
 			addDbcError(dbc, "HY090", NULL, 0);
@@ -210,11 +210,15 @@ SQLGetConnectAttrW(SQLHDBC ConnectionHan
 	switch (Attribute) {
 	/* all string attributes */
 	case SQL_ATTR_CURRENT_CATALOG:
-		ptr = malloc(BufferLength);
-		if (ptr == NULL) {
-			/* Memory allocation error */
-			addDbcError(dbc, "HY001", NULL, 0);
-			return SQL_ERROR;
+	case SQL_ATTR_TRACEFILE:
+	case SQL_ATTR_TRANSLATE_LIB:
+		if (BufferLength > 0) {
+			ptr = malloc(BufferLength);
+			if (ptr == NULL) {
+				/* Memory allocation error */
+				addDbcError(dbc, "HY001", NULL, 0);
+				return SQL_ERROR;
+			}
 		}
 		break;
 	default: