mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-20 18:32:01 +00:00
cleanups and fixes that cppcheck found
This commit is contained in:
parent
322fbaf389
commit
7d2a2f2ade
3 changed files with 16 additions and 3 deletions
3
exec.c
3
exec.c
|
@ -644,7 +644,8 @@ static int qc_print(qc_program *prog)
|
|||
const char *laststr = NULL;
|
||||
for (i = 0; i < (size_t)prog->argc; ++i) {
|
||||
qcany *str = (qcany*)(prog->globals + OFS_PARM0 + 3*i);
|
||||
printf("%s", (laststr = prog_getstring(prog, str->string)));
|
||||
laststr = prog_getstring(prog, str->string);
|
||||
printf("%s", laststr);
|
||||
}
|
||||
if (laststr && (prog->xflags & VMXF_TRACE)) {
|
||||
size_t len = strlen(laststr);
|
||||
|
|
6
parser.c
6
parser.c
|
@ -1921,6 +1921,12 @@ static ast_expression* process_condition(parser_t *parser, ast_expression *cond,
|
|||
/* use the right NOT_ */
|
||||
prev = cond;
|
||||
cond = (ast_expression*)ast_unary_new(ast_ctx(cond), type_not_instr[cond->expression.vtype], cond);
|
||||
|
||||
/*
|
||||
* cppcheck: it thinks there is a possible null pointer dereference
|
||||
* otherwise it would be "redundant" to check it ast_unary_new returned
|
||||
* null, it's wrong.
|
||||
*/
|
||||
if (!cond) {
|
||||
ast_unref(prev);
|
||||
parseerror(parser, "internal error: failed to process condition");
|
||||
|
|
10
test.c
10
test.c
|
@ -414,7 +414,10 @@ bool task_template_generate(task_template_t *template, char tag, const char *fil
|
|||
* Value will contain a newline character at the end, we need to strip
|
||||
* this otherwise kaboom, seriously, kaboom :P
|
||||
*/
|
||||
*strrchr(value, '\n')='\0';
|
||||
if (strchr(value, '\n'))
|
||||
*strrchr(value, '\n')='\0';
|
||||
else /* cppcheck: possible nullpointer dereference */
|
||||
abort();
|
||||
|
||||
/*
|
||||
* Now allocate and set the actual value for the specific tag. Which
|
||||
|
@ -515,7 +518,10 @@ bool task_template_parse(const char *file, task_template_t *template, FILE *fp)
|
|||
* Value will contain a newline character at the end, we need to strip
|
||||
* this otherwise kaboom, seriously, kaboom :P
|
||||
*/
|
||||
*strrchr(value, '\n')='\0';
|
||||
if (strrchr(value, '\n'))
|
||||
*strrchr(value, '\n')='\0';
|
||||
else /* cppcheck: possible null pointer dereference */
|
||||
abort();
|
||||
|
||||
vec_push(template->comparematch, util_strdup(value));
|
||||
|
||||
|
|
Loading…
Reference in a new issue