some extra NULL checks to please cppchecker

This commit is contained in:
iceman1001 2025-03-25 12:34:00 +01:00
commit 363bc0da8a

View file

@ -3601,16 +3601,32 @@ static const TRexChar *trex_matchnode(TRex *exp, TRexNode *node, const TRexChar
/* public api */
TRex *trex_compile(const TRexChar *pattern, const TRexChar **error, int flags) {
TRex *exp = (TRex *)malloc(sizeof(TRex));
if (exp == NULL) {
return NULL;
}
exp->_eol = exp->_bol = NULL;
exp->_p = pattern;
exp->_nallocated = (int)scstrlen(pattern) * sizeof(TRexChar);
exp->_nodes = (TRexNode *)malloc(exp->_nallocated * sizeof(TRexNode));
if (exp->_nodes == NULL) {
trex_free(exp);
return NULL;
}
exp->_nsize = 0;
exp->_matches = 0;
exp->_nsubexpr = 0;
exp->_first = trex_newnode(exp, OP_EXPR);
exp->_error = error;
exp->_jmpbuf = malloc(sizeof(jmp_buf));
if (exp->_jmpbuf == NULL) {
trex_free(exp);
return NULL;
}
exp->_flags = flags;
if (setjmp(*((jmp_buf *)exp->_jmpbuf)) == 0) {
int res = trex_list(exp);