[Bugfix][T106][bug-view-229]Fix the memory leak issue of the data module -- sqlite3_free *sql
Only Configure: Yes
Affected branch: master
Affected module: data
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: yes
Doc Update: No
Change-Id: Idc3691688043c025f239a704ef1e2d27ba619883
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
index 78fc8b2..23a7831 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
@@ -454,6 +454,7 @@
char *zErrMsg = 0;
int rc;
int idx = 0;
+ char sql[128]={0};
/* Open database */
pthread_mutex_lock(&s_qser_data_database_mutex);
@@ -467,7 +468,7 @@
LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__);
/* Create SQL statement */
- char *sql = sqlite3_mprintf("SELECT ID from LYNQAPN WHERE HANDLE=%d", handle);
+ sprintf(sql,"SELECT ID from LYNQAPN WHERE HANDLE=%d", handle);
LYINFLOG("sql: %s\n", sql);
/* Execute SQL statement */
rc = sqlite3_exec(apnDb, sql, apn_db_handle_get_profile_cb, &idx, &zErrMsg);
@@ -552,7 +553,7 @@
{
char *zErrMsg = 0;
int rc;
- //char sql[128]={0};
+ char sql[128]={0};
if(!lynq_check_index(profile_idx))
{
return LYNQ_E_APN_DB_FAIL;
@@ -570,7 +571,7 @@
LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__);
/* Create SQL statement */
//sql = "SELECT * from LYNQAPN";
- char *sql = sqlite3_mprintf("UPDATE LYNQAPN SET HANDLE=%d WHERE ID=%d", handle, (int)profile_idx);
+ sprintf(sql,"UPDATE LYNQAPN SET HANDLE=%d WHERE ID=%d", handle, (int)profile_idx);
LYINFLOG("sql: %s\n", sql);
/* Execute SQL statement */
rc = sqlite3_exec(apnDb, sql, NULL, NULL, &zErrMsg);
@@ -605,8 +606,8 @@
{
char *zErrMsg = 0;
int rc;
+ char sql[128]={0};
- //char sql[128]={0};
if(!lynq_check_index(profile_idx))
{
return LYNQ_E_APN_DB_FAIL;
@@ -623,7 +624,7 @@
LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__);
/* Create SQL statement */
- char *sql = sqlite3_mprintf("SELECT HANDLE from LYNQAPN WHERE ID=%d", (int)profile_idx);
+ sprintf(sql,"SELECT HANDLE from LYNQAPN WHERE ID=%d", (int)profile_idx);
LYINFLOG("sql: %s\n", sql);
/* Execute SQL statement */
rc = sqlite3_exec(apnDb, sql, apn_db_handle_get_cb, handle, &zErrMsg);
@@ -836,6 +837,7 @@
char *zErrMsg = 0;
int rc;
int default_handle = LYNQ_APN_CHANNEL_MAX + 1;
+ char sql[128]={0};
/* Open database */
pthread_mutex_lock(&s_qser_data_database_mutex);
@@ -849,7 +851,7 @@
LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__);
/* Create SQL statement */
- char *sql = sqlite3_mprintf("UPDATE LYNQAPN SET HANDLE=%d", default_handle);
+ sprintf(sql,"UPDATE LYNQAPN SET HANDLE=%d", default_handle);
LYINFLOG("sql: %s\n", sql);
/* Execute SQL statement */
rc = sqlite3_exec(apnDb, sql, NULL, NULL, &zErrMsg);
@@ -946,6 +948,7 @@
LYINFLOG("the profile id is %d\n", profile_id);
char *sql = sqlite3_mprintf("INSERT INTO LYNQAPN VALUES('%d','%d','%d','%q','%q','%q','%q','%d')", profile_id, apn->pdp_type, apn->auth_proto, apn->apn_name, apn->username, apn->password, apn->apn_type, default_handle);
rc = sqlite3_exec(apnDb, sql, NULL, NULL, &zErrMsg);
+ sqlite3_free(sql);
if( rc != SQLITE_OK )
{
LYERRLOG( "SQL error: %s", zErrMsg);
@@ -964,6 +967,7 @@
{
char *zErrMsg = 0;
int rc;
+ char sql[128]={0};
if(!lynq_check_index(profile_idx))
{
@@ -981,8 +985,7 @@
LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__);
/* Create SQL statement */
- //sql = "SELECT * from LYNQAPN";
- char *sql = sqlite3_mprintf("DELETE from LYNQAPN WHERE ID=%d",(int)profile_idx);
+ sprintf(sql,"DELETE from LYNQAPN WHERE ID=%d",(int)profile_idx);
LYINFLOG("sql: %s\n", sql);
/* Execute SQL statement */
rc = sqlite3_exec(apnDb, sql, NULL, NULL, &zErrMsg);
@@ -1025,6 +1028,7 @@
LYINFLOG("sql: %s\n", sql);
/* Execute SQL statement */
rc = sqlite3_exec(apnDb, sql, NULL, NULL, &zErrMsg);
+ sqlite3_free(sql);
if( rc != SQLITE_OK )
{
LYERRLOG("SQL error: %s\n", zErrMsg);
@@ -1063,6 +1067,7 @@
{
char *zErrMsg = 0;
int rc;
+ char sql[128]={0};
if(!lynq_check_index(profile_idx))
{
@@ -1080,7 +1085,7 @@
LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__);
/* Create SQL statement */
- char *sql = sqlite3_mprintf("SELECT * from LYNQAPN WHERE ID=%d", (int)profile_idx);
+ sprintf(sql,"SELECT * from LYNQAPN WHERE ID=%d", (int)profile_idx);
LYINFLOG("sql: %s\n", sql);
/* Execute SQL statement */
rc = sqlite3_exec(apnDb, sql, lynq_apn_db_query_cb, (qser_apn_info_s *)apn, &zErrMsg);
@@ -1122,6 +1127,7 @@
{
char *zErrMsg = 0;
int rc;
+ char sql[128]={0};
/* Open database */
apn_count = 0;
@@ -1137,7 +1143,7 @@
LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__);
/* Create SQL statement */
- char *sql = sqlite3_mprintf("SELECT * from LYNQAPN");
+ sprintf(sql,"SELECT * from LYNQAPN");
LYINFLOG("sql: %s\n", sql);
/* Execute SQL statement */
rc = sqlite3_exec(apnDb, sql, apn_db_query_list_cb, (qser_apn_info_list_s *)apn_list, &zErrMsg);