- memory leak in label construction
- gvedit compilation errors out, but works if manually compiled with qt5 #1862
- incorrect HTML BR attribute parsing code #1913
+- broken overflow checks in RectArea #1906
## [2.46.0] - 2021-01-18
| Calculate the n-dimensional area of a rectangle
-----------------------------------------------------------------------------*/
-#if LLONG_MAX > UINT_MAX
unsigned int RectArea(Rect_t * r)
{
int i;
if (Undefined(r))
return 0;
- /*
- * XXX add overflow checks
- */
area = 1;
for (i = 0; i < NUMDIMS; i++) {
- long long a_test = area * (r->boundary[i + NUMDIMS] - r->boundary[i]);
- if( a_test > UINT_MAX) {
+ unsigned int dim = r->boundary[i + NUMDIMS] - r->boundary[i];
+ if (dim == 0) return 0;
+ if (UINT_MAX / dim < area) {
agerr (AGERR, "label: area too large for rtree\n");
return UINT_MAX;
}
- area = a_test;
+ area *= dim;
}
return area;
}
-#else
-unsigned int RectArea(Rect_t * r)
-{
- int i;
- unsigned int area=1, a=1;
- assert(r);
-
- if (Undefined(r)) return 0;
-
- /*
- * XXX add overflow checks
- */
- area = 1;
- for (i = 0; i < NUMDIMS; i++) {
- unsigned int b = r->boundary[i + NUMDIMS] - r->boundary[i];
- if (b==0) return 0;
- a *= b;
- if( (a / b ) != area) {
- agerr (AGERR, "label: area too large for rtree\n");
- return UINT_MAX;
- }
- area = a;
- }
- return area;
-}
-#endif /*LLONG_MAX > UINT_MAX*/
-#if 0 /*original code*/
-int RectArea(Rect_t * r)
-{
- int i, area=1;
- assert(r);
-
- if (Undefined(r))
- return 0;
- area = 1;
- for (i = 0; i < NUMDIMS; i++) {
- area *= r->boundary[i + NUMDIMS] - r->boundary[i];
- }
- return area;
-}
-#endif
/*-----------------------------------------------------------------------------
| Combine two rectangles, make one that includes both.
assert 'style=dashed' in output, 'style=dashed not found in DOT output'
assert 'penwidth=2' in output, 'penwidth=2 not found in DOT output'
-@pytest.mark.xfail(strict=True) # FIXME
def test_1906():
'''
graphs that cause an overflow during rectangle calculation should result in