forked from bartvdbraak/blender
fix for [#11691] No checks in curve code for "Number of points <= Order U"
added checks for a nurbes orderu being larger then pntsu. This has the same effect as the curve having only 1 point. (its display list is not generated but it is still added but a dummy displist with zero points is made) memcpy was also being used where the memory overlaped (probably worked in most cases but this is incorrect and valgrind complained), use memmove instead.
This commit is contained in:
parent
81dee8e1dd
commit
d3f7fba472
@ -1476,7 +1476,9 @@ void makeBevelList(Object *ob)
|
||||
else nu= cu->nurb.first;
|
||||
|
||||
while(nu) {
|
||||
if(nu->pntsu<=1) {
|
||||
/* check we are a single point? also check we are not a surface and that the orderu is sane,
|
||||
* enforced in the UI but can go wrong possibly */
|
||||
if(nu->pntsu<2 || ((nu->type & 7)==CU_NURBS && nu->pntsu < nu->orderu)) {
|
||||
bl= MEM_callocN(sizeof(BevList)+1*sizeof(BevPoint), "makeBevelList");
|
||||
BLI_addtail(&(cu->bev), bl);
|
||||
bl->nr= 0;
|
||||
|
@ -783,7 +783,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
|
||||
else
|
||||
resolu= nu->resolu;
|
||||
|
||||
if(nu->pntsu<2);
|
||||
if(nu->pntsu<2 || ((nu->type & 7)==CU_NURBS && nu->pntsu < nu->orderu));
|
||||
else if((nu->type & 7)==CU_BEZIER) {
|
||||
|
||||
/* count */
|
||||
|
@ -3658,6 +3658,11 @@ void delNurb()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Never allow the order to exceed the number of points */
|
||||
if ((nu->type & 7)==CU_NURBS && (nu->pntsu < nu->orderu)) {
|
||||
nu->orderu = nu->pntsu;
|
||||
}
|
||||
nu= next;
|
||||
}
|
||||
/* 2nd loop, delete small pieces: just for curves */
|
||||
@ -3669,7 +3674,7 @@ void delNurb()
|
||||
bezt= nu->bezt;
|
||||
for(a=0;a<nu->pntsu;a++) {
|
||||
if( BEZSELECTED_HIDDENHANDLES(bezt) ) {
|
||||
memcpy(bezt, bezt+1, (nu->pntsu-a-1)*sizeof(BezTriple));
|
||||
memmove(bezt, bezt+1, (nu->pntsu-a-1)*sizeof(BezTriple));
|
||||
nu->pntsu--;
|
||||
a--;
|
||||
event= 1;
|
||||
@ -3690,7 +3695,7 @@ void delNurb()
|
||||
|
||||
for(a=0;a<nu->pntsu;a++) {
|
||||
if( bp->f1 & SELECT ) {
|
||||
memcpy(bp, bp+1, (nu->pntsu-a-1)*sizeof(BPoint));
|
||||
memmove(bp, bp+1, (nu->pntsu-a-1)*sizeof(BPoint));
|
||||
nu->pntsu--;
|
||||
a--;
|
||||
event= 1;
|
||||
@ -3704,6 +3709,11 @@ void delNurb()
|
||||
memcpy(bp1, nu->bp, (nu->pntsu)*sizeof(BPoint) );
|
||||
MEM_freeN(nu->bp);
|
||||
nu->bp= bp1;
|
||||
|
||||
/* Never allow the order to exceed the number of points */
|
||||
if ((nu->type & 7)==CU_NURBS && (nu->pntsu < nu->orderu)) {
|
||||
nu->orderu = nu->pntsu;
|
||||
}
|
||||
}
|
||||
makeknots(nu, 1, nu->flagu>>1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user