From fbf8e0d5bcc4f231e820bcea04e503be8e3ac125 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sun, 24 Dec 2023 00:36:21 -0500 Subject: [PATCH] static analyzer warnings for mon.c src/mon.c(2370): warning: Dereferencing NULL pointer '((mtmp2))->mextra->epri'. src/mon.c(2375): warning: Dereferencing NULL pointer '((mtmp2))->mextra->eshk'. src/mon.c(2380): warning: Dereferencing NULL pointer '((mtmp2))->mextra->emin'. src/mon.c(2385): warning: Dereferencing NULL pointer '((mtmp2))->mextra->edog'. src/mon.c(4419): warning: Dereferencing NULL pointer 'ga.animal_list'. --- src/mon.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mon.c b/src/mon.c index bc1bd839b..348c9b982 100644 --- a/src/mon.c +++ b/src/mon.c @@ -2362,26 +2362,31 @@ copy_mextra(struct monst* mtmp2, struct monst* mtmp1) if (EGD(mtmp1)) { if (!EGD(mtmp2)) newegd(mtmp2); + assert(has_egd(mtmp2)); *EGD(mtmp2) = *EGD(mtmp1); } if (EPRI(mtmp1)) { if (!EPRI(mtmp2)) newepri(mtmp2); + assert(has_epri(mtmp2)); *EPRI(mtmp2) = *EPRI(mtmp1); } if (ESHK(mtmp1)) { if (!ESHK(mtmp2)) neweshk(mtmp2); + assert(has_eshk(mtmp2)); *ESHK(mtmp2) = *ESHK(mtmp1); } if (EMIN(mtmp1)) { if (!EMIN(mtmp2)) newemin(mtmp2); + assert(has_emin(mtmp2)); *EMIN(mtmp2) = *EMIN(mtmp1); } if (EDOG(mtmp1)) { if (!EDOG(mtmp2)) newedog(mtmp2); + assert(has_edog(mtmp2)); *EDOG(mtmp2) = *EDOG(mtmp1); } if (has_mcorpsenm(mtmp1)) @@ -4415,7 +4420,7 @@ pick_animal(void) if (!ga.animal_list) mon_animal_list(TRUE); - + assert(ga.animal_list != 0); res = ga.animal_list[rn2(ga.animal_list_count)]; /* rogue level should use monsters represented by uppercase letters only, but since chameleons aren't generated there (not uppercase!)