Warning from static code analysis

Issue #26 resolved
Davide Faconti created an issue

Hi,

there is something suspicious about this code in nlopt_ik.cpp

if (grad!=NULL) {
      for (uint i=0; i<n; i++) {
        double o=vals[i];
        vals[i]=o+jump;
        double v1[m];
        c->cartSumSquaredError(vals, v1);
        vals[i]=o-jump;
        double v2[m];
        c->cartSumSquaredError(vals, v2);
        vals[i]=o;
        for (uint j=0; j<m; j++)  {
          grad[j*n+i]=(v1[j]-v2[j])/(2*jump);
        }
      }
    }

First of all m is not known at compile time, and can't be used for C99 style arrays. if you really want a vector of size m you should use

std::vector<double> v1(m)

Comments (2)

  1. Log in to comment