From aa3429ebb2ae31c578fd6a02a1ed7df3e97dfe08 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 30 Aug 2018 20:04:36 +0200 Subject: [PATCH] Fix defect detected by coverity scan (avoid null pointer dereference) --- src/tests/system-tests/libs/geofunctions.cc | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/tests/system-tests/libs/geofunctions.cc b/src/tests/system-tests/libs/geofunctions.cc index 8098609c1..8c1b985a0 100644 --- a/src/tests/system-tests/libs/geofunctions.cc +++ b/src/tests/system-tests/libs/geofunctions.cc @@ -328,17 +328,10 @@ arma::mat Euler_to_CTM(const arma::vec &eul) double sin_psi = sin(eul(2)); double cos_psi = cos(eul(2)); - arma::mat C = arma::zeros(3, 3); // Calculate coordinate transformation matrix using (2.22) - C(0, 0) = cos_theta * cos_psi; - C(0, 1) = cos_theta * sin_psi; - C(0, 2) = -sin_theta; - C(1, 0) = -cos_phi * sin_psi + sin_phi * sin_theta * cos_psi; - C(1, 1) = cos_phi * cos_psi + sin_phi * sin_theta * sin_psi; - C(1, 2) = sin_phi * cos_theta; - C(2, 0) = sin_phi * sin_psi + cos_phi * sin_theta * cos_psi; - C(2, 1) = -sin_phi * cos_psi + cos_phi * sin_theta * sin_psi; - C(2, 2) = cos_phi * cos_theta; + arma::mat C = {{cos_theta * cos_psi, cos_theta * sin_psi, -sin_theta}, + {-cos_phi * sin_psi + sin_phi * sin_theta * cos_psi, cos_phi * cos_psi + sin_phi * sin_theta * sin_psi, sin_phi * cos_theta}, + {sin_phi * sin_psi + cos_phi * sin_theta * cos_psi, -sin_phi * cos_psi + cos_phi * sin_theta * sin_psi, cos_phi * cos_theta}}; return C; }