From 363bc0da8a12debcdd303191a768330802f3b815 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 25 Mar 2025 12:34:00 +0100 Subject: [PATCH] some extra NULL checks to please cppchecker --- client/deps/cliparser/argtable3.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client/deps/cliparser/argtable3.c b/client/deps/cliparser/argtable3.c index f5b7950cd..0680e8dc9 100644 --- a/client/deps/cliparser/argtable3.c +++ b/client/deps/cliparser/argtable3.c @@ -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);