psqlodbc.git / summary / log / commit / refs
commit ae12eef5ccb754d1cd9a4f12e8e88e56e0497bc2
Author: Hiroshi Inoue <h-inoue@dream.email.ne.jp>
Date: Thu Jun 22 21:33:05 2017 +0000
Fix the bug reported by Keith Handlon.
Skip malloc(0) in build_libpq_bind_params(). malloc(0) seems to return NULL on AIX, whereas it returns non-NULL on Windows or linux.
convert.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/convert.c b/convert.c
index f6d4886e..cb9ae545 100644
--- a/convert.c
+++ b/convert.c
@@ -3692,19 +3692,22 @@ build_libpq_bind_params(StatementClass *stmt,
if (QB_initialize(&qb, MIN_ALC_SIZE, stmt, RPM_BUILDING_BIND_REQUEST) < 0)
return FALSE;
- *paramTypes = malloc(sizeof(OID) * num_params);
- if (*paramTypes == NULL)
- goto cleanup;
- *paramValues = malloc(sizeof(char *) * num_params);
- if (*paramValues == NULL)
- goto cleanup;
- memset(*paramValues, 0, sizeof(char *) * num_params);
- *paramLengths = malloc(sizeof(int) * num_params);
- if (*paramLengths == NULL)
- goto cleanup;
- *paramFormats = malloc(sizeof(int) * num_params);
- if (*paramFormats == NULL)
- goto cleanup;
+ if (num_params > 0)
+ {
+ *paramTypes = malloc(sizeof(OID) * num_params);
+ if (*paramTypes == NULL)
+ goto cleanup;
+ *paramValues = malloc(sizeof(char *) * num_params);
+ if (*paramValues == NULL)
+ goto cleanup;
+ memset(*paramValues, 0, sizeof(char *) * num_params);
+ *paramLengths = malloc(sizeof(int) * num_params);
+ if (*paramLengths == NULL)
+ goto cleanup;
+ *paramFormats = malloc(sizeof(int) * num_params);
+ if (*paramFormats == NULL)
+ goto cleanup;
+ }
qb.flags |= FLGB_BINARY_AS_POSSIBLE;
[parent: b9ff28c506c4]