diff options
author | Ton Roosendaal <ton@blender.org> | 2010-12-03 20:31:34 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2010-12-03 20:31:34 +0300 |
commit | 990b487c730ac192405682fa45232f6542cdd14c (patch) | |
tree | cf864489d2fcc5db8fa9fc130d48b1189425b44f /source/blender/blenkernel/intern/curve.c | |
parent | 263830f0004481cd4921f03f4242d7c80794b08d (diff) |
Bugfix #25026
Nurbs edit: 'switch order' crashed when order was higher than amount of
points.
Diffstat (limited to 'source/blender/blenkernel/intern/curve.c')
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index d5d13c9badd..9be64e27d20 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -2906,38 +2906,41 @@ void switchdirectionNurb(Nurb *nu) bp2--; } if(nu->type == CU_NURBS) { - /* inverse knots */ - a= KNOTSU(nu); - fp1= nu->knotsu; - fp2= fp1+(a-1); - a/= 2; - while(fp1!=fp2 && a>0) { - SWAP(float, *fp1, *fp2); - a--; - fp1++; - fp2--; - } - /* and make in increasing order again */ - a= KNOTSU(nu); - fp1= nu->knotsu; - fp2=tempf= MEM_mallocN(sizeof(float)*a, "switchdirect"); - while(a--) { - fp2[0]= fabs(fp1[1]-fp1[0]); - fp1++; - fp2++; - } - - a= KNOTSU(nu)-1; - fp1= nu->knotsu; - fp2= tempf; - fp1[0]= 0.0; - fp1++; - while(a--) { - fp1[0]= fp1[-1]+fp2[0]; + /* no knots for too short paths */ + if(nu->knotsu) { + /* inverse knots */ + a= KNOTSU(nu); + fp1= nu->knotsu; + fp2= fp1+(a-1); + a/= 2; + while(fp1!=fp2 && a>0) { + SWAP(float, *fp1, *fp2); + a--; + fp1++; + fp2--; + } + /* and make in increasing order again */ + a= KNOTSU(nu); + fp1= nu->knotsu; + fp2=tempf= MEM_mallocN(sizeof(float)*a, "switchdirect"); + while(a--) { + fp2[0]= fabs(fp1[1]-fp1[0]); + fp1++; + fp2++; + } + + a= KNOTSU(nu)-1; + fp1= nu->knotsu; + fp2= tempf; + fp1[0]= 0.0; fp1++; - fp2++; + while(a--) { + fp1[0]= fp1[-1]+fp2[0]; + fp1++; + fp2++; + } + MEM_freeN(tempf); } - MEM_freeN(tempf); } } else { |