pointer check
This commit is contained in:
parent
fcf39a444a
commit
f684e12c27
|
@ -2240,6 +2240,10 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
|||
} else if (tTagIsJson(data)) {
|
||||
char* jsonString = NULL;
|
||||
parseTagDatatoJson(data, &jsonString);
|
||||
if(jsonString == NULL) {
|
||||
tscError("doConvertJson error: parseTagDatatoJson failed");
|
||||
return terrno;
|
||||
}
|
||||
STR_TO_VARSTR(dst, jsonString);
|
||||
taosMemoryFree(jsonString);
|
||||
} else if (jsonInnerType == TSDB_DATA_TYPE_NCHAR) { // value -> "value"
|
||||
|
|
|
@ -417,6 +417,10 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) {
|
|||
}
|
||||
char* pJson = NULL;
|
||||
parseTagDatatoJson(pTag, &pJson);
|
||||
if(pJson == NULL) {
|
||||
uError("parseTagDatatoJson failed, pJson == NULL");
|
||||
goto end;
|
||||
}
|
||||
cJSON* tag = cJSON_CreateObject();
|
||||
RAW_NULL_CHECK(tag);
|
||||
STagVal* pTagVal = taosArrayGet(pTagVals, 0);
|
||||
|
@ -727,6 +731,10 @@ static void processAlterTable(SMqMetaRsp* metaRsp, cJSON** pJson) {
|
|||
goto end;
|
||||
}
|
||||
parseTagDatatoJson(vAlterTbReq.pTagVal, &buf);
|
||||
if(buf == NULL) {
|
||||
uError("parseTagDatatoJson failed, buf == NULL");
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
if (vAlterTbReq.tagType == TSDB_DATA_TYPE_VARBINARY) {
|
||||
buf = taosMemoryCalloc(vAlterTbReq.nTagVal * 2 + 2 + 3, 1);
|
||||
|
|
|
@ -448,6 +448,10 @@ int32_t ctgGetTbTag(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName,
|
|||
|
||||
char* pJson = NULL;
|
||||
parseTagDatatoJson(pTag, &pJson);
|
||||
if(NULL == pJson) {
|
||||
taosArrayDestroy(pTagVals);
|
||||
CTG_ERR_JRET(terrno);
|
||||
}
|
||||
STagVal tagVal;
|
||||
tagVal.cid = 0;
|
||||
tagVal.type = TSDB_DATA_TYPE_JSON;
|
||||
|
|
|
@ -2093,6 +2093,10 @@ int32_t ctgHandleGetTbTagRsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf*
|
|||
|
||||
char* pJson = NULL;
|
||||
parseTagDatatoJson(pTag, &pJson);
|
||||
if (NULL == pJson) {
|
||||
taosArrayDestroy(pTagVals);
|
||||
CTG_ERR_JRET(terrno);
|
||||
}
|
||||
STagVal tagVal;
|
||||
tagVal.cid = 0;
|
||||
tagVal.type = TSDB_DATA_TYPE_JSON;
|
||||
|
|
|
@ -565,6 +565,10 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
if (tTagIsJson(pTag)) {
|
||||
char* pJson = NULL;
|
||||
parseTagDatatoJson(pTag, &pJson);
|
||||
if(NULL == pJson) {
|
||||
qError("failed to parse tag to json, pJson is NULL");
|
||||
return terrno;
|
||||
}
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s", pJson);
|
||||
taosMemoryFree(pJson);
|
||||
|
||||
|
|
|
@ -1114,6 +1114,10 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo,
|
|||
if (tagType == TSDB_DATA_TYPE_JSON) {
|
||||
char* tagJson = NULL;
|
||||
parseTagDatatoJson(tagData, &tagJson);
|
||||
if (tagJson == NULL) {
|
||||
code = terrno;
|
||||
goto _end;
|
||||
}
|
||||
tagVarChar = taosMemoryMalloc(strlen(tagJson) + VARSTR_HEADER_SIZE);
|
||||
QUERY_CHECK_NULL(tagVarChar, code, lino, _end, terrno);
|
||||
memcpy(varDataVal(tagVarChar), tagJson, strlen(tagJson));
|
||||
|
|
|
@ -900,6 +900,9 @@ int32_t convertDataBlockToUdfDataBlock(SSDataBlock *block, SUdfDataBlock *udfBlo
|
|||
udfCol->colData.fixLenCol.dataLen = colDataGetLength(col, udfBlock->numOfRows);
|
||||
int32_t dataLen = udfCol->colData.fixLenCol.dataLen;
|
||||
udfCol->colData.fixLenCol.data = taosMemoryMalloc(udfCol->colData.fixLenCol.dataLen);
|
||||
if (NULL == udfCol->colData.fixLenCol.data) {
|
||||
return terrno;
|
||||
}
|
||||
char *data = udfCol->colData.fixLenCol.data;
|
||||
memcpy(data, col->pData, dataLen);
|
||||
}
|
||||
|
|
|
@ -92,6 +92,9 @@ int32_t udfdCPluginUdfInitLoadAggFuncs(SUdfCPluginCtx *udfCtx, const char *udfNa
|
|||
int32_t udfdCPluginUdfInit(SScriptUdfInfo *udf, void **pUdfCtx) {
|
||||
int32_t err = 0;
|
||||
SUdfCPluginCtx *udfCtx = taosMemoryCalloc(1, sizeof(SUdfCPluginCtx));
|
||||
if (NULL == udfCtx) {
|
||||
return terrno;
|
||||
}
|
||||
err = uv_dlopen(udf->path, &udfCtx->lib);
|
||||
if (err != 0) {
|
||||
fnError("can not load library %s. error: %s", udf->path, uv_strerror(err));
|
||||
|
@ -606,6 +609,9 @@ int32_t udfdInitUdf(char *udfName, SUdf *udf) {
|
|||
|
||||
int32_t udfdNewUdf(SUdf **pUdf, const char *udfName) {
|
||||
SUdf *udfNew = taosMemoryCalloc(1, sizeof(SUdf));
|
||||
if (NULL == udfNew) {
|
||||
return terrno;
|
||||
}
|
||||
udfNew->refCount = 1;
|
||||
udfNew->lastFetchTime = taosGetTimestampMs();
|
||||
strncpy(udfNew->name, udfName, TSDB_FUNC_NAME_LEN);
|
||||
|
@ -1105,6 +1111,9 @@ int32_t udfdFillUdfInfoFromMNode(void *clientRpc, char *udfName, SUdf *udf) {
|
|||
taosArrayDestroy(retrieveReq.pFuncNames);
|
||||
|
||||
SUdfdRpcSendRecvInfo *msgInfo = taosMemoryCalloc(1, sizeof(SUdfdRpcSendRecvInfo));
|
||||
if(NULL == msgInfo) {
|
||||
return terrno;
|
||||
}
|
||||
msgInfo->rpcType = UDFD_RPC_RETRIVE_FUNC;
|
||||
msgInfo->param = udf;
|
||||
if(uv_sem_init(&msgInfo->resultSem, 0) != 0) {
|
||||
|
|
|
@ -514,6 +514,9 @@ end:
|
|||
taosArrayDestroy(pTagVals);
|
||||
if (string == NULL) {
|
||||
string = taosStrdup(TSDB_DATA_NULL_STR_L);
|
||||
if(string == NULL) {
|
||||
qError("failed to strdup null string");
|
||||
}
|
||||
}
|
||||
*jsonStr = string;
|
||||
}
|
||||
|
@ -629,6 +632,7 @@ int32_t cloneSVreateTbReq(SVCreateTbReq* pSrc, SVCreateTbReq** pDst) {
|
|||
(*pDst)->flags = pSrc->flags;
|
||||
if (pSrc->name) {
|
||||
(*pDst)->name = taosStrdup(pSrc->name);
|
||||
if (NULL == (*pDst)->name) goto _exit;
|
||||
}
|
||||
(*pDst)->uid = pSrc->uid;
|
||||
(*pDst)->btime = pSrc->btime;
|
||||
|
@ -636,21 +640,25 @@ int32_t cloneSVreateTbReq(SVCreateTbReq* pSrc, SVCreateTbReq** pDst) {
|
|||
(*pDst)->commentLen = pSrc->commentLen;
|
||||
if (pSrc->comment) {
|
||||
(*pDst)->comment = taosStrdup(pSrc->comment);
|
||||
if (NULL == (*pDst)->comment) goto _exit;
|
||||
}
|
||||
(*pDst)->type = pSrc->type;
|
||||
|
||||
if (pSrc->type == TSDB_CHILD_TABLE) {
|
||||
if (pSrc->ctb.stbName) {
|
||||
(*pDst)->ctb.stbName = taosStrdup(pSrc->ctb.stbName);
|
||||
if (NULL == (*pDst)->ctb.stbName) goto _exit;
|
||||
}
|
||||
(*pDst)->ctb.tagNum = pSrc->ctb.tagNum;
|
||||
(*pDst)->ctb.suid = pSrc->ctb.suid;
|
||||
if (pSrc->ctb.tagName) {
|
||||
(*pDst)->ctb.tagName = taosArrayDup(pSrc->ctb.tagName, NULL);
|
||||
if (NULL == (*pDst)->ctb.tagName) goto _exit;
|
||||
}
|
||||
STag* pTag = (STag*)pSrc->ctb.pTag;
|
||||
if (pTag) {
|
||||
(*pDst)->ctb.pTag = taosMemoryMalloc(pTag->len);
|
||||
if(NULL == (*pDst)->ctb.pTag) goto _exit;
|
||||
memcpy((*pDst)->ctb.pTag, pTag, pTag->len);
|
||||
}
|
||||
} else {
|
||||
|
@ -658,11 +666,17 @@ int32_t cloneSVreateTbReq(SVCreateTbReq* pSrc, SVCreateTbReq** pDst) {
|
|||
(*pDst)->ntb.schemaRow.version = pSrc->ntb.schemaRow.nCols;
|
||||
if (pSrc->ntb.schemaRow.nCols > 0 && pSrc->ntb.schemaRow.pSchema) {
|
||||
(*pDst)->ntb.schemaRow.pSchema = taosMemoryMalloc(pSrc->ntb.schemaRow.nCols * sizeof(SSchema));
|
||||
if (NULL == (*pDst)->ntb.schemaRow.pSchema) goto _exit;
|
||||
memcpy((*pDst)->ntb.schemaRow.pSchema, pSrc->ntb.schemaRow.pSchema, pSrc->ntb.schemaRow.nCols * sizeof(SSchema));
|
||||
}
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_exit:
|
||||
tdDestroySVCreateTbReq(*pDst);
|
||||
taosMemoryFree(*pDst);
|
||||
return terrno;
|
||||
}
|
||||
|
||||
void freeDbCfgInfo(SDbCfgInfo* pInfo) {
|
||||
|
|
|
@ -85,6 +85,9 @@ int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int3
|
|||
|
||||
int32_t bufLen = tSerializeSTableInfoReq(NULL, 0, &infoReq);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
if (NULL == pBuf) {
|
||||
return terrno;
|
||||
}
|
||||
if(tSerializeSTableInfoReq(pBuf, bufLen, &infoReq) < 0)
|
||||
{
|
||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||
|
@ -112,6 +115,9 @@ int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *ms
|
|||
|
||||
int32_t bufLen = tSerializeSUseDbReq(NULL, 0, &usedbReq);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
if (NULL == pBuf) {
|
||||
return terrno;
|
||||
}
|
||||
if(tSerializeSUseDbReq(pBuf, bufLen, &usedbReq) < 0)
|
||||
{
|
||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||
|
@ -133,6 +139,9 @@ int32_t queryBuildQnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t
|
|||
|
||||
int32_t bufLen = tSerializeSQnodeListReq(NULL, 0, &qnodeListReq);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
if (NULL == pBuf) {
|
||||
return terrno;
|
||||
}
|
||||
if(tSerializeSQnodeListReq(pBuf, bufLen, &qnodeListReq) < 0)
|
||||
{
|
||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||
|
@ -154,6 +163,9 @@ int32_t queryBuildDnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t
|
|||
|
||||
int32_t bufLen = tSerializeSDnodeListReq(NULL, 0, &dnodeListReq);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
if (NULL == pBuf) {
|
||||
return terrno;
|
||||
}
|
||||
if(tSerializeSDnodeListReq(pBuf, bufLen, &dnodeListReq) < 0)
|
||||
{
|
||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||
|
@ -174,6 +186,9 @@ int32_t queryBuildGetSerVerMsg(void *input, char **msg, int32_t msgSize, int32_t
|
|||
|
||||
int32_t bufLen = tSerializeSServerVerReq(NULL, 0, &req);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
if (NULL == pBuf) {
|
||||
return terrno;
|
||||
}
|
||||
if(tSerializeSServerVerReq(pBuf, bufLen, &req) < 0)
|
||||
{
|
||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||
|
@ -195,6 +210,9 @@ int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t
|
|||
|
||||
int32_t bufLen = tSerializeSDbCfgReq(NULL, 0, &dbCfgReq);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
if (NULL == pBuf) {
|
||||
return terrno;
|
||||
}
|
||||
if(tSerializeSDbCfgReq(pBuf, bufLen, &dbCfgReq) < 0)
|
||||
{
|
||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||
|
@ -216,6 +234,9 @@ int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t
|
|||
|
||||
int32_t bufLen = tSerializeSUserIndexReq(NULL, 0, &indexReq);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
if (NULL == pBuf) {
|
||||
return terrno;
|
||||
}
|
||||
if(tSerializeSUserIndexReq(pBuf, bufLen, &indexReq) < 0)
|
||||
{
|
||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||
|
@ -247,8 +268,13 @@ int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int3
|
|||
|
||||
int32_t bufLen = tSerializeSRetrieveFuncReq(NULL, 0, &funcReq);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
if (NULL == pBuf) {
|
||||
taosArrayDestroy(funcReq.pFuncNames);
|
||||
return terrno;
|
||||
}
|
||||
if(tSerializeSRetrieveFuncReq(pBuf, bufLen, &funcReq) < 0)
|
||||
{
|
||||
taosArrayDestroy(funcReq.pFuncNames);
|
||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||
}
|
||||
|
||||
|
@ -270,6 +296,9 @@ int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32
|
|||
|
||||
int32_t bufLen = tSerializeSGetUserAuthReq(NULL, 0, &req);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
if (NULL == pBuf) {
|
||||
return terrno;
|
||||
}
|
||||
if (tSerializeSGetUserAuthReq(pBuf, bufLen, &req) < 0) {
|
||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||
}
|
||||
|
@ -290,6 +319,9 @@ int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_
|
|||
|
||||
int32_t bufLen = tSerializeSTableIndexReq(NULL, 0, &indexReq);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
if (NULL == pBuf) {
|
||||
return terrno;
|
||||
}
|
||||
if(tSerializeSTableIndexReq(pBuf, bufLen, &indexReq) < 0)
|
||||
{
|
||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||
|
@ -314,6 +346,9 @@ int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t
|
|||
|
||||
int32_t bufLen = tSerializeSTableCfgReq(NULL, 0, &cfgReq);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
if (NULL == pBuf) {
|
||||
return terrno;
|
||||
}
|
||||
if(tSerializeSTableCfgReq(pBuf, bufLen, &cfgReq) < 0)
|
||||
{
|
||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||
|
@ -335,6 +370,9 @@ int32_t queryBuildGetViewMetaMsg(void *input, char **msg, int32_t msgSize, int32
|
|||
|
||||
int32_t bufLen = tSerializeSViewMetaReq(NULL, 0, &req);
|
||||
void *pBuf = (*mallcFp)(bufLen);
|
||||
if (NULL == pBuf) {
|
||||
return terrno;
|
||||
}
|
||||
if(tSerializeSViewMetaReq(pBuf, bufLen, &req) < 0)
|
||||
{
|
||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||
|
@ -357,6 +395,9 @@ int32_t queryBuildGetTableTSMAMsg(void *input, char **msg, int32_t msgSize, int3
|
|||
|
||||
int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
|
||||
void * pBuf = (*mallcFp)(bufLen);
|
||||
if (NULL == pBuf) {
|
||||
return terrno;
|
||||
}
|
||||
if(tSerializeTableTSMAInfoReq(pBuf, bufLen, &req) < 0)
|
||||
{
|
||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||
|
@ -379,6 +420,10 @@ int32_t queryBuildGetTSMAMsg(void *input, char **msg, int32_t msgSize, int32_t *
|
|||
|
||||
int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req);
|
||||
void * pBuf = (*mallcFp)(bufLen);
|
||||
if(pBuf == NULL)
|
||||
{
|
||||
return terrno;
|
||||
}
|
||||
if(tSerializeTableTSMAInfoReq(pBuf, bufLen, &req) < 0)
|
||||
{
|
||||
return TSDB_CODE_TSC_INVALID_INPUT;
|
||||
|
@ -396,6 +441,9 @@ int32_t queryBuildGetStreamProgressMsg(void* input, char** msg, int32_t msgSize,
|
|||
|
||||
int32_t len = tSerializeStreamProgressReq(NULL, 0, input);
|
||||
void* pBuf = (*mallcFp)(len);
|
||||
if (NULL == pBuf) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if(tSerializeStreamProgressReq(pBuf, len, input) < 0)
|
||||
{
|
||||
|
@ -666,6 +714,9 @@ int32_t queryProcessGetSerVerRsp(void *output, char *msg, int32_t msgSize) {
|
|||
}
|
||||
|
||||
*(char **)output = taosStrdup(out.ver);
|
||||
if (NULL == *(char **)output) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue