fix invalid read in construct_vsites
authorHan Wang <han.wang@fu-berlin.de>
Wed, 23 Jan 2013 21:02:22 +0000 (14:02 -0700)
committerChristoph Junghans <junghans@votca.org>
Thu, 24 Jan 2013 23:01:39 +0000 (16:01 -0700)
* aj is not available in the F_VSITEN case hence cannot be read in
  the common part of the function

Change-Id: Ic98dfb91eb095aea933abc3dbfb4f5cc10bf4166

src/mdlib/vsite.c

index 34a340b74f0d33d8731327670b2625bb4d7bb3c9..2eadddecb1febfdadb17c219822a8863395912c3 100644 (file)
@@ -484,7 +484,6 @@ void construct_vsites(FILE *log,gmx_vsite_t *vsite,
        /* The vsite and constructing atoms */
        avsite = ia[1];
        ai   = ia[2];
-       aj   = ia[3];
 
        /* Constants for constructing vsites */
        a1   = ip[tp].vsite.a;
@@ -512,30 +511,36 @@ void construct_vsites(FILE *log,gmx_vsite_t *vsite,
        inc = nra+1;
        switch (ftype) {
        case F_VSITE2:
+         aj = ia[3];
          constr_vsite2(x[ai],x[aj],x[avsite],a1,pbc_null2);
          break;
        case F_VSITE3:
+         aj = ia[3];
          ak = ia[4];
          b1 = ip[tp].vsite.b;
          constr_vsite3(x[ai],x[aj],x[ak],x[avsite],a1,b1,pbc_null2);
          break;
        case F_VSITE3FD:
+         aj = ia[3];
          ak = ia[4];
          b1 = ip[tp].vsite.b;
          constr_vsite3FD(x[ai],x[aj],x[ak],x[avsite],a1,b1,pbc_null2);
          break;
        case F_VSITE3FAD:
+         aj = ia[3];
          ak = ia[4];
          b1 = ip[tp].vsite.b;
          constr_vsite3FAD(x[ai],x[aj],x[ak],x[avsite],a1,b1,pbc_null2);
          break;
        case F_VSITE3OUT:
+         aj = ia[3];
          ak = ia[4];
          b1 = ip[tp].vsite.b;
          c1 = ip[tp].vsite.c;
          constr_vsite3OUT(x[ai],x[aj],x[ak],x[avsite],a1,b1,c1,pbc_null2);
          break;
        case F_VSITE4FD:
+         aj = ia[3];
          ak = ia[4];
          al = ia[5];
          b1 = ip[tp].vsite.b;
@@ -544,6 +549,7 @@ void construct_vsites(FILE *log,gmx_vsite_t *vsite,
                          pbc_null2);
          break;
        case F_VSITE4FDN:
+         aj = ia[3];
          ak = ia[4];
          al = ia[5];
          b1 = ip[tp].vsite.b;