From 456a7fa8cc998508b6ce89b592c2c00c0d9975e1 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Wed, 26 Feb 2020 01:48:40 +0400 Subject: [PATCH] [mod_pgsql,mod_mariadb] Fix scan-build warnings. --- src/mod/databases/mod_mariadb/mod_mariadb.c | 11 +++-------- src/mod/databases/mod_pgsql/mod_pgsql.c | 4 +++- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/mod/databases/mod_mariadb/mod_mariadb.c b/src/mod/databases/mod_mariadb/mod_mariadb.c index 05151d4c89..cdd64ffb81 100644 --- a/src/mod/databases/mod_mariadb/mod_mariadb.c +++ b/src/mod/databases/mod_mariadb/mod_mariadb.c @@ -685,15 +685,10 @@ error: err_str = mariadb_handle_get_error(handle); if (zstr(err_str)) { - if (zstr(er)) { - err_str = strdup((char *)"SQL ERROR!"); - } else { - err_str = er; - } + switch_safe_free(err_str); + err_str = (er) ? er : strdup((char *)"SQL ERROR!"); } else { - if (!zstr(er)) { - free(er); - } + switch_safe_free(er); } if (err_str) { diff --git a/src/mod/databases/mod_pgsql/mod_pgsql.c b/src/mod/databases/mod_pgsql/mod_pgsql.c index b69d54f497..a534594548 100644 --- a/src/mod/databases/mod_pgsql/mod_pgsql.c +++ b/src/mod/databases/mod_pgsql/mod_pgsql.c @@ -565,7 +565,9 @@ switch_status_t database_handle_exec_string(switch_database_interface_handle_t * goto error; } - if (result) { + if (!result) { + goto done; + } else { switch (result->status) { #if POSTGRESQL_MAJOR_VERSION >= 9 && POSTGRESQL_MINOR_VERSION >= 2 case PGRES_SINGLE_TUPLE: