提交 211c079b 编写于 作者: M markswang

[TD-5534]<fix>:fix the coverity high risk of client

上级 4216a400
...@@ -726,13 +726,12 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_prepareStmtImp(J ...@@ -726,13 +726,12 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_prepareStmtImp(J
TAOS_STMT* pStmt = taos_stmt_init(tscon); TAOS_STMT* pStmt = taos_stmt_init(tscon);
int32_t code = taos_stmt_prepare(pStmt, str, len); int32_t code = taos_stmt_prepare(pStmt, str, len);
tfree(str);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
jniError("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code)); jniError("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code));
free(str);
return JNI_TDENGINE_ERROR; return JNI_TDENGINE_ERROR;
} }
free(str);
return (jlong) pStmt; return (jlong) pStmt;
} }
...@@ -920,10 +919,6 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI ...@@ -920,10 +919,6 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI
char* curTags = tagsData; char* curTags = tagsData;
TAOS_BIND *tagsBind = calloc(numOfTags, sizeof(TAOS_BIND)); TAOS_BIND *tagsBind = calloc(numOfTags, sizeof(TAOS_BIND));
if (tagsBind == NULL) {
jniError("numOfTags:%d, alloc memory failed", numOfTags);
return JNI_OUT_OF_MEMORY;
}
for(int32_t i = 0; i < numOfTags; ++i) { for(int32_t i = 0; i < numOfTags; ++i) {
tagsBind[i].buffer_type = typeArray[i]; tagsBind[i].buffer_type = typeArray[i];
tagsBind[i].buffer = curTags; tagsBind[i].buffer = curTags;
...@@ -942,14 +937,13 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI ...@@ -942,14 +937,13 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI
tfree(lengthArray); tfree(lengthArray);
tfree(typeArray); tfree(typeArray);
tfree(nullArray); tfree(nullArray);
tfree(tagsBind);
(*env)->ReleaseStringUTFChars(env, tableName, name); (*env)->ReleaseStringUTFChars(env, tableName, name);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
jniError("jobj:%p, conn:%p, code:%s", jobj, tsconn, tstrerror(code)); jniError("jobj:%p, conn:%p, code:%s", jobj, tsconn, tstrerror(code));
free(tagsBind);
return JNI_TDENGINE_ERROR; return JNI_TDENGINE_ERROR;
} }
free(tagsBind);
return JNI_SUCCESS; return JNI_SUCCESS;
} }
...@@ -979,12 +973,11 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J ...@@ -979,12 +973,11 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(J
(*env)->ReleaseStringUTFChars(env, line, c_lines[i]); (*env)->ReleaseStringUTFChars(env, line, c_lines[i]);
} }
tfree(c_lines);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
jniError("jobj:%p, conn:%p, code:%s", jobj, taos, tstrerror(code)); jniError("jobj:%p, conn:%p, code:%s", jobj, taos, tstrerror(code));
free(c_lines);
return JNI_TDENGINE_ERROR; return JNI_TDENGINE_ERROR;
} }
free(c_lines);
return code; return code;
} }
\ No newline at end of file
...@@ -443,11 +443,10 @@ int32_t tscCreateGlobalMergerEnv(SQueryInfo *pQueryInfo, tExtMemBuffer ***pMemBu ...@@ -443,11 +443,10 @@ int32_t tscCreateGlobalMergerEnv(SQueryInfo *pQueryInfo, tExtMemBuffer ***pMemBu
} }
pModel = createColumnModel(pSchema, (int32_t)size, capacity); pModel = createColumnModel(pSchema, (int32_t)size, capacity);
tfree(pSchema);
if (pModel == NULL){ if (pModel == NULL){
tfree(pSchema);
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
tfree(pSchema);
int32_t pg = DEFAULT_PAGE_SIZE; int32_t pg = DEFAULT_PAGE_SIZE;
int32_t overhead = sizeof(tFilePage); int32_t overhead = sizeof(tFilePage);
......
...@@ -701,14 +701,14 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols ...@@ -701,14 +701,14 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols
TAOS_STMT* stmt = taos_stmt_init(taos); TAOS_STMT* stmt = taos_stmt_init(taos);
if (stmt == NULL) { if (stmt == NULL) {
free(sql); tfree(sql);
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
code = taos_stmt_prepare(stmt, sql, (unsigned long)strlen(sql)); code = taos_stmt_prepare(stmt, sql, (unsigned long)strlen(sql));
free(sql); tfree(sql);
if (code != 0) { if (code != 0) {
free(stmt); tfree(stmt);
tscError("%s", taos_stmt_errstr(stmt)); tscError("%s", taos_stmt_errstr(stmt));
return code; return code;
} }
...@@ -717,7 +717,7 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols ...@@ -717,7 +717,7 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols
code = taos_stmt_set_tbname(stmt, cTableName); code = taos_stmt_set_tbname(stmt, cTableName);
if (code != 0) { if (code != 0) {
tscError("%s", taos_stmt_errstr(stmt)); tscError("%s", taos_stmt_errstr(stmt));
free(stmt); tfree(stmt);
return code; return code;
} }
...@@ -727,13 +727,13 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols ...@@ -727,13 +727,13 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols
code = taos_stmt_bind_param(stmt, colsBinds); code = taos_stmt_bind_param(stmt, colsBinds);
if (code != 0) { if (code != 0) {
tscError("%s", taos_stmt_errstr(stmt)); tscError("%s", taos_stmt_errstr(stmt));
free(stmt); tfree(stmt);
return code; return code;
} }
code = taos_stmt_add_batch(stmt); code = taos_stmt_add_batch(stmt);
if (code != 0) { if (code != 0) {
tscError("%s", taos_stmt_errstr(stmt)); tscError("%s", taos_stmt_errstr(stmt));
free(stmt); tfree(stmt);
return code; return code;
} }
} }
......
...@@ -8362,7 +8362,7 @@ static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SSqlObj* pS ...@@ -8362,7 +8362,7 @@ static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SSqlObj* pS
if (subInfo->aliasName.n > 0) { if (subInfo->aliasName.n > 0) {
if (subInfo->aliasName.n >= TSDB_TABLE_FNAME_LEN) { if (subInfo->aliasName.n >= TSDB_TABLE_FNAME_LEN) {
free(pTableMetaInfo1); tfree(pTableMetaInfo1);
return invalidOperationMsg(msgBuf, "subquery alias name too long"); return invalidOperationMsg(msgBuf, "subquery alias name too long");
} }
...@@ -8376,7 +8376,7 @@ static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SSqlObj* pS ...@@ -8376,7 +8376,7 @@ static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SSqlObj* pS
STableMetaInfo** tmp = realloc(pQueryInfo->pTableMetaInfo, (pQueryInfo->numOfTables + 1) * POINTER_BYTES); STableMetaInfo** tmp = realloc(pQueryInfo->pTableMetaInfo, (pQueryInfo->numOfTables + 1) * POINTER_BYTES);
if (tmp == NULL) { if (tmp == NULL) {
free(pTableMetaInfo1); tfree(pTableMetaInfo1);
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
......
...@@ -2055,7 +2055,7 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) { ...@@ -2055,7 +2055,7 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
} }
if (!tIsValidSchema(pTableMeta->schema, pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.numOfTags)) { if (!tIsValidSchema(pTableMeta->schema, pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.numOfTags)) {
tscError("0x%"PRIx64" invalid table meta from mnode, name:%s", pSql->self, tNameGetTableName(&pTableMetaInfo->name)); tscError("0x%"PRIx64" invalid table meta from mnode, name:%s", pSql->self, tNameGetTableName(&pTableMetaInfo->name));
free(pTableMeta); tfree(pTableMeta);
return TSDB_CODE_TSC_INVALID_VALUE; return TSDB_CODE_TSC_INVALID_VALUE;
} }
......
...@@ -2476,7 +2476,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { ...@@ -2476,7 +2476,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
pState->states = calloc(pState->numOfSub, sizeof(*pState->states)); pState->states = calloc(pState->numOfSub, sizeof(*pState->states));
if (pState->states == NULL) { if (pState->states == NULL) {
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
tscDestroyGlobalMergerEnv(pMemoryBuf, pDesc,pState->numOfSub); tscDestroyGlob alMergerEnv(pMemoryBuf, pDesc,pState->numOfSub);
tscAsyncResultOnError(pSql); tscAsyncResultOnError(pSql);
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册