Skip to content

Commit a9d0ae5

Browse files
committed
fix: avoid crash on postgres when these functions are called with NULL values for db and data
1 parent 0f3ab4b commit a9d0ae5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/dbutils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ int dbutils_settings_set_key_value (db_t *db, cloudsync_context *data, const cha
164164
DEBUG_SETTINGS("dbutils_settings_set_key_value key: %s value: %s", key, value);
165165

166166
int rc = DBRES_OK;
167-
if (db == NULL) db = cloudsync_db(data);
167+
if (db == NULL && data != NULL) db = cloudsync_db(data);
168168

169169
if (key && value) {
170170
const char *values[] = {key, value};
@@ -288,7 +288,7 @@ int dbutils_table_settings_set_key_value (db_t *db, cloudsync_context *data, con
288288
DEBUG_SETTINGS("dbutils_table_settings_set_key_value table: %s column: %s key: %s", table, column, key);
289289

290290
int rc = DBRES_OK;
291-
if (db == NULL) db = cloudsync_db(data);
291+
if (db == NULL && data != NULL) db = cloudsync_db(data);
292292

293293
// sanity check tbl_name
294294
if (table == NULL) {

0 commit comments

Comments
 (0)