dtinfo/DtSR: coverity CID 88552; memory corruption
This commit is contained in:
@@ -333,7 +333,7 @@ DtSR_SearchResultsEntry::create_matches()
|
|||||||
DtSrHitword* kwics = NULL;
|
DtSrHitword* kwics = NULL;
|
||||||
long n_kwics = 0;
|
long n_kwics = 0;
|
||||||
|
|
||||||
char* parseout = NULL;
|
const char* parseout = NULL;
|
||||||
|
|
||||||
// hack! overwrite f_language, since austext's value is wrong
|
// hack! overwrite f_language, since austext's value is wrong
|
||||||
// In future, the next lines should be removed.
|
// In future, the next lines should be removed.
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ using namespace std;
|
|||||||
#define True 1
|
#define True 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
StringParser::brute_force(const char* text_in, int n_of_pats,
|
StringParser::brute_force(const char* text_in, int n_of_pats,
|
||||||
const char* patterns, int sensitive)
|
const char* patterns, int sensitive)
|
||||||
{
|
{
|
||||||
@@ -238,18 +238,12 @@ StringParser::brute_force(const char* text_in, int n_of_pats,
|
|||||||
if (caped_text)
|
if (caped_text)
|
||||||
delete[] caped_text;
|
delete[] caped_text;
|
||||||
|
|
||||||
string trunstr = text_run.str();
|
static string trunstr = text_run.str();
|
||||||
char* ret_text = (char *)trunstr.c_str();
|
|
||||||
|
|
||||||
if (ret_text == NULL)
|
if (!trunstr.size())
|
||||||
return NULL;
|
return NULL;
|
||||||
else if (*ret_text == '\0') {
|
|
||||||
delete[] ret_text;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return ret_text;
|
|
||||||
|
|
||||||
|
return trunstr.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
@@ -332,16 +326,12 @@ StringParser::project_textrun(const char* org_textrun)
|
|||||||
const char *
|
const char *
|
||||||
StringParser::hilite(const char* text, int n, const char* pats)
|
StringParser::hilite(const char* text, int n, const char* pats)
|
||||||
{
|
{
|
||||||
char* textrun = brute_force(text, n, pats);
|
const char* textrun = brute_force(text, n, pats);
|
||||||
|
|
||||||
if (textrun == NULL)
|
if (textrun == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
delete[] textrun;
|
return project_textrun(textrun);
|
||||||
|
|
||||||
const char* prjed_textrun = project_textrun(textrun);
|
|
||||||
|
|
||||||
return prjed_textrun;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public:
|
|||||||
static const char *
|
static const char *
|
||||||
hilite(const char* text, int n, const char* pats);
|
hilite(const char* text, int n, const char* pats);
|
||||||
|
|
||||||
static char *
|
static const char *
|
||||||
brute_force(const char* text, int, const char* pats, int sensitive = 0);
|
brute_force(const char* text, int, const char* pats, int sensitive = 0);
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
|
|||||||
Reference in New Issue
Block a user