@@ -193,7 +193,13 @@ int test_init (const char *db_path, int init) {
193193
194194 // init network with connection string + apikey
195195 char network_init [512 ];
196- snprintf (network_init , sizeof (network_init ), "SELECT cloudsync_network_init('%s?apikey=%s');" , getenv ("CONNECTION_STRING" ), getenv ("APIKEY" ));
196+ const char * conn_str = getenv ("CONNECTION_STRING" );
197+ const char * apikey = getenv ("APIKEY" );
198+ if (!conn_str || !apikey ) {
199+ fprintf (stderr , "Error: CONNECTION_STRING or APIKEY not set.\n" );
200+ exit (1 );
201+ }
202+ snprintf (network_init , sizeof (network_init ), "SELECT cloudsync_network_init('%s?apikey=%s');" , conn_str , apikey );
197203 rc = db_exec (db , network_init ); RCHECK
198204
199205 rc = db_expect_int (db , "SELECT COUNT(*) as count FROM activities;" , 0 ); RCHECK
@@ -255,7 +261,13 @@ int test_enable_disable(const char *db_path) {
255261
256262 // init network with connection string + apikey
257263 char network_init [512 ];
258- snprintf (network_init , sizeof (network_init ), "SELECT cloudsync_network_init('%s?apikey=%s');" , getenv ("CONNECTION_STRING" ), getenv ("APIKEY" ));
264+ const char * conn_str = getenv ("CONNECTION_STRING" );
265+ const char * apikey = getenv ("APIKEY" );
266+ if (!conn_str || !apikey ) {
267+ fprintf (stderr , "Error: CONNECTION_STRING or APIKEY not set.\n" );
268+ exit (1 );
269+ }
270+ snprintf (network_init , sizeof (network_init ), "SELECT cloudsync_network_init('%s?apikey=%s');" , conn_str , apikey );
259271 rc = db_exec (db , network_init ); RCHECK
260272
261273 rc = db_exec (db , "SELECT cloudsync_network_send_changes();" ); RCHECK
0 commit comments