Commit 76900b83 authored by Adrian Diaz's avatar Adrian Diaz
Browse files

avoids the possibility of undefined behavior with memcpy having the same...

avoids the possibility of undefined behavior with memcpy having the same source and destination arrays; this is not every instance of this issue in the source code
parent 3e4fd3da
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ int mldivide3(const double m[3][3], const double *v, double *ans)
      if (fabs(aug[j][i]) > fabs(aug[i][i])) {
        double tempv[4];
        memcpy(tempv,aug[i],4*sizeof(double));
        memcpy(aug[i],aug[j],4*sizeof(double));
        memmove(aug[i],aug[j],4*sizeof(double));
        memcpy(aug[j],tempv,4*sizeof(double));
      }
    }
@@ -68,7 +68,7 @@ int mldivide3(const double m[3][3], const double *v, double *ans)
      if (p != i) {
        double tempv[4];
        memcpy(tempv,aug[i],4*sizeof(double));
        memcpy(aug[i],aug[p],4*sizeof(double));
        memmove(aug[i],aug[p],4*sizeof(double));
        memcpy(aug[p],tempv,4*sizeof(double));
      }

+2 −2
Original line number Diff line number Diff line
@@ -537,7 +537,7 @@ void RCB::compute(int dimension, int n, double **x, double *wt,
      if (dotmark[i] == markactive)
        memcpy(&buf[outgoing++],&dots[i],sizeof(Dot));
      else
        memcpy(&dots[keep++],&dots[i],sizeof(Dot));
        memmove(&dots[keep++],&dots[i],sizeof(Dot));
    }

    // post receives for dots
@@ -1029,7 +1029,7 @@ void RCB::compute_old(int dimension, int n, double **x, double *wt,
      if (dotmark[i] == markactive)
        memcpy(&buf[outgoing++],&dots[i],sizeof(Dot));
      else
        memcpy(&dots[keep++],&dots[i],sizeof(Dot));
        memmove(&dots[keep++],&dots[i],sizeof(Dot));
    }

    // post receives for dots