Merge pull request #27006 from taosdata/fix/TD-31163-3.0
fix: memleak in initWktRegex
This commit is contained in:
commit
70f4bec00b
|
@ -156,6 +156,10 @@ _exit:
|
|||
int32_t executeGeomFromTextFunc(SColumnInfoData *pInputData, int32_t i, SColumnInfoData *pOutputData) {
|
||||
int32_t code = TSDB_CODE_FAILED;
|
||||
|
||||
if (!IS_VAR_DATA_TYPE((pInputData)->info.type)) {
|
||||
return TSDB_CODE_FUNC_FUNTION_PARA_VALUE;
|
||||
}
|
||||
|
||||
char *input = colDataGetData(pInputData, i);
|
||||
unsigned char *output = NULL;
|
||||
|
||||
|
|
|
@ -147,7 +147,17 @@ static int32_t initWktRegex(pcre2_code **ppRegex, pcre2_match_data **ppMatchData
|
|||
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *))*( *)\\)))( *))*( *)\\)))( *))*( "
|
||||
"*)\\)))|(GEOCOLLECTION\\((?R)(( *)(,)( *)(?R))*( *)\\))( *)$");
|
||||
|
||||
code = doRegComp(ppRegex, ppMatchData, wktPatternWithSpace);
|
||||
pcre2_code *pRegex = NULL;
|
||||
pcre2_match_data *pMatchData = NULL;
|
||||
code = doRegComp(&pRegex, &pMatchData, wktPatternWithSpace);
|
||||
if (code < 0) {
|
||||
taosMemoryFree(wktPatternWithSpace);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
*ppRegex = pRegex;
|
||||
*ppMatchData = pMatchData;
|
||||
|
||||
taosMemoryFree(wktPatternWithSpace);
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -5,14 +5,24 @@ int32_t doRegComp(pcre2_code** ppRegex, pcre2_match_data** ppMatchData, const ch
|
|||
int errorcode;
|
||||
PCRE2_SIZE erroroffset;
|
||||
|
||||
*ppRegex = pcre2_compile((PCRE2_SPTR8)pattern, PCRE2_ZERO_TERMINATED, options, &errorcode, &erroroffset, NULL);
|
||||
if (*ppRegex == NULL) {
|
||||
pcre2_code* pRegex = NULL;
|
||||
pcre2_match_data* pMatchData = NULL;
|
||||
|
||||
pRegex = pcre2_compile((PCRE2_SPTR8)pattern, PCRE2_ZERO_TERMINATED, options, &errorcode, &erroroffset, NULL);
|
||||
if (pRegex == NULL) {
|
||||
PCRE2_UCHAR buffer[256];
|
||||
(void)pcre2_get_error_message(errorcode, buffer, sizeof(buffer));
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*ppMatchData = pcre2_match_data_create_from_pattern(*ppRegex, NULL);
|
||||
pMatchData = pcre2_match_data_create_from_pattern(pRegex, NULL);
|
||||
if (pMatchData == NULL) {
|
||||
pcre2_code_free(pRegex);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*ppRegex = pRegex;
|
||||
*ppMatchData = pMatchData;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue