]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
mpi: remove NULL checks before frees
authorPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 21 Nov 2023 20:58:36 +0000 (21:58 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 21 Nov 2023 20:58:36 +0000 (21:58 +0100)
As Coverity points out, paths reaching these NULL checks will
have already dereferenced the pointers. So use the same condition
as for the allocation.

mpi/libmpiwrap.c

index df0a1ae9df065a0ab0b7b5c32c1ac122ca1ef148..24221f810866d5503a133fdf50cd201982fa40cc 100644 (file)
@@ -869,9 +869,15 @@ void walk_type ( void(*f)(void*,long), char* base, MPI_Datatype ty )
    }
 
    /* normal exit */
-   if (ints)  free(ints);
-   if (addrs) free(addrs);
-   if (dtys)  free(dtys);
+   if (n_ints > 0) {
+      free(ints);
+   }
+   if (n_addrs > 0) {
+      free(addrs);
+   }
+   if (n_dtys) {
+      free(dtys);
+   }
    return;
 
   unhandled: