]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/commitdiff
Protect usage of `n` when it is `nullptr`
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Thu, 20 Jun 2019 11:29:33 +0000 (13:29 +0200)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Thu, 20 Jun 2019 11:29:33 +0000 (13:29 +0200)
decision_control/slotplanner.cc

index 8ac19e8e33bbde5ae265bcaec4991d72a215bc54..3f903aa6527a8a2a0be99d78de7bf80c6e3b26de 100644 (file)
@@ -827,14 +827,14 @@ struct SamplingInfo ParallelSlot::getSamplingInfo()
 {
         struct SamplingInfo si;
         RRTNode *n = this->getMidd();
+        if (n == nullptr)
+                return si;
         BicycleCar *bc = new BicycleCar(n->x(), n->y(), n->h());
         RRTNode *cc;
         if (this->slotSide() == LEFT)
                 cc = bc->ccl();
         else
                 cc = bc->ccr();
-        if (n == nullptr)
-                return si;
         if (this->slotType() == PARALLEL) {
                 BicycleCar *nbc = bc->move(cc, this->slotHeading() - n->h());
                 si.x0 = nbc->x();