Skip to content

Commit 58ad0f5

Browse files
committed
Merge pull request kbengine#151 from linjx/master
dbinterface == NULL 判断提前
2 parents 63ed1d4 + d1cc468 commit 58ad0f5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

kbe/src/lib/dbmgr_lib/db_interface.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ bool DBUtil::initialize()
8383

8484
if(dbcfg.db_passwordEncrypt)
8585
{
86-
// 如果小于64则表示目前还是明文密码
86+
// 如果小于64则表示目前还是明文密码
8787
if(strlen(dbcfg.db_password) < 64)
8888
{
8989
WARNING_MSG(fmt::format("DBUtil::createInterface: db password is not encrypted!\nplease use password(rsa):\n{}\n",
@@ -121,19 +121,19 @@ DBInterface* DBUtil::createInterface(bool showinfo)
121121
dbinterface = new DBInterfaceMysql(dbcfg.db_unicodeString_characterSet, dbcfg.db_unicodeString_collation);
122122
}
123123

124+
if(dbinterface == NULL)
125+
{
126+
ERROR_MSG("DBUtil::createInterface: can't create dbinterface!\n");
127+
return NULL;
128+
}
129+
124130
kbe_snprintf(dbinterface->db_type_, MAX_BUF, "%s", dbcfg.db_type);
125131
dbinterface->db_port_ = dbcfg.db_port;
126132
kbe_snprintf(dbinterface->db_ip_, MAX_IP, "%s", dbcfg.db_ip);
127133
kbe_snprintf(dbinterface->db_username_, MAX_BUF, "%s", dbcfg.db_username);
128134
dbinterface->db_numConnections_ = dbcfg.db_numConnections;
129135
kbe_snprintf(dbinterface->db_password_, MAX_BUF, "%s", dbcfg.db_password);
130136

131-
if(dbinterface == NULL)
132-
{
133-
ERROR_MSG("DBUtil::createInterface: can't create dbinterface!\n");
134-
return NULL;
135-
}
136-
137137
if(!dbinterface->attach(DBUtil::dbname()))
138138
{
139139
ERROR_MSG(fmt::format("DBUtil::createInterface: can't attach to database!\n\tdbinterface={0:p}\n\targs={1}",

0 commit comments

Comments
 (0)