From 63d4e530261df333b2539054ee8490335c4d9843 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 4 Dec 2020 17:06:36 +0100 Subject: [PATCH] Please cppcheck. --- examples/smpi/ampi_test/ampi_test.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/smpi/ampi_test/ampi_test.cpp b/examples/smpi/ampi_test/ampi_test.cpp index bc02cadd84..696f27a3b6 100644 --- a/examples/smpi/ampi_test/ampi_test.cpp +++ b/examples/smpi/ampi_test/ampi_test.cpp @@ -12,8 +12,11 @@ int main(int argc, char* argv[]) MPI_Init(&argc, &argv); // useless alocations for testing and coverage void* pointer = malloc(100 * sizeof(int)); - pointer = realloc(pointer, 50 * sizeof(int)); - pointer = realloc(pointer, 200 * sizeof(int)); + void* ptmp; + if ((ptmp = realloc(pointer, 50 * sizeof(int))) != NULL) + pointer = ptmp; + if ((ptmp = realloc(pointer, 200 * sizeof(int))) != NULL) + pointer = ptmp; free(pointer); pointer = calloc(100, sizeof(int)); int rank; -- 2.20.1