IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Opened 16 years ago

Closed 16 years ago

#1412 closed defect (fixed)

X2, Y2 may be used uninitialized in this function: libdvo/src/coordops.c

Reported by: Michael Wood-Vasey Owned by: Michael Wood-Vasey
Priority: normal Milestone:
Component: DVO Version: current
Severity: minor Keywords:
Cc:

Description

The following snippet triggers an objection by the compiler because it doesn't know that X2, Y2 will be defined. I've restructured this to put the seond if statement inside the first, but actually I'd argue that X2, Y2, X3, Y3 are unnecessary optimizations. The compiler is smart enough to figure this out.

---

if (coords[0].Npolyterms > 1) {

X2 = X*X;
Y2 = Y*Y;
XY = X*Y;
*L += X2*coords[0].polyterms[0][0] + XY*coords[0].polyterms[1][0] + Y2*coords[0].polyterms[2][0];
*M += X2*coords[0].polyterms[0][1] + XY*coords[0].polyterms[1][1] + Y2*coords[0].polyterms[2][1];

}
if (coords[0].Npolyterms > 2) {

X3 = X2*X;
Y3 = Y2*Y;
*L += X3*coords[0].polyterms[3][0] + X2*Y*coords[0].polyterms[4][0] + X*Y2*coords[0].polyterms[5][0] + Y3*coords[0].polyterms[6][0];
*M += X3*coords[0].polyterms[3][1] + X2*Y*coords[0].polyterms[4][1] + X*Y2*coords[0].polyterms[5][1] + Y3*coords[0].polyterms[6][1];

}

---

Change History (2)

comment:1 by Michael Wood-Vasey, 16 years ago

Owner: changed from wmwood-vasey to Michael Wood-Vasey
Status: newaccepted

comment:2 by Michael Wood-Vasey, 16 years ago

Resolution: fixed
Status: acceptedclosed

I've checked in the fix as SVN r28837.

---

if (coords[0].Npolyterms > 1) {

X2 = X*X;
Y2 = Y*Y;
XY = X*Y;
*L += X2*coords[0].polyterms[0][0] + XY*coords[0].polyterms[1][0] + Y2*coords[0].polyterms[2][0];
*M += X2*coords[0].polyterms[0][1] + XY*coords[0].polyterms[1][1] + Y2*coords[0].polyterms[2][1];

if (coords[0].Npolyterms > 2) {

X3 = X2*X;
Y3 = Y2*Y;
*L += X3*coords[0].polyterms[3][0] + X2*Y*coords[0].polyterms[4][0] + X*Y2*coords[0].polyterms[5][0] + Y3*coords[0].polyterms[6][0];
*M += X3*coords[0].polyterms[3][1] + X2*Y*coords[0].polyterms[4][1] + X*Y2*coords[0].polyterms[5][1] + Y3*coords[0].polyterms[6][1];

}

}

---

Note: See TracTickets for help on using tickets.