Skip to content

Commit 0ebc038

Browse files
committed
Add nullbyte size in malloc, run client tests in mac
1 parent bfbffd8 commit 0ebc038

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

ci/scripts/run-tests-mac.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ wait_for_pg(){
2222
# Start database
2323
brew services start postgresql@$PG_VERSION
2424

25-
wait_for_pg && cd $WORKDIR/build && make test && make test-parallel
25+
wait_for_pg && cd $WORKDIR/build && make test && make test-parallel && make test-client

test/c/runner.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct TestCase
1919
PGconn *connect_database(
2020
const char *db_host, const char *db_port, const char *db_user, const char *db_password, const char *db_name)
2121
{
22-
const int const_db_uri_chars = strlen("host= port= user= dbname= sslmode=disable password=");
22+
const int const_db_uri_chars = strlen("host= port= user= dbname= sslmode=disable password=") + 1;
2323
char *db_uri = malloc(strlen(db_host) + strlen(db_port) + strlen(db_user) + strlen(db_password) + strlen(db_name)
2424
+ const_db_uri_chars);
2525
sprintf(db_uri,
@@ -44,7 +44,7 @@ PGconn *connect_database(
4444
int recreate_database(PGconn *root_conn, const char *test_db_name)
4545
{
4646
char *statement = "DROP DATABASE IF EXISTS ";
47-
char *full_statement = malloc(strlen(statement) + strlen(test_db_name));
47+
char *full_statement = malloc(strlen(statement) + strlen(test_db_name) + 1);
4848
sprintf(full_statement, "%s%s", statement, test_db_name);
4949
PGresult *res = PQexec(root_conn, full_statement);
5050
free(full_statement);
@@ -56,7 +56,7 @@ int recreate_database(PGconn *root_conn, const char *test_db_name)
5656
}
5757

5858
statement = "CREATE DATABASE ";
59-
full_statement = malloc(strlen(statement) + strlen(test_db_name));
59+
full_statement = malloc(strlen(statement) + strlen(test_db_name) + 1);
6060
sprintf(full_statement, "%s%s", statement, test_db_name);
6161
res = PQexec(root_conn, full_statement);
6262
free(full_statement);

test/c/test_op_rewrite.c

-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#ifndef TEST_OP_REWRITE_H
2-
#define TEST_OP_REWRITE_H
3-
41
#include <libpq-fe.h>
52

63
int test_op_rewrite(PGconn *conn)
@@ -51,4 +48,3 @@ int test_op_rewrite(PGconn *conn)
5148
}
5249
return 0;
5350
}
54-
#endif

0 commit comments

Comments
 (0)