]> granicus.if.org Git - graphviz/commitdiff
neatogen: fix miscalculation of intermediate edge resources
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 15 Nov 2022 04:36:15 +0000 (20:36 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 17 Nov 2022 04:03:16 +0000 (20:03 -0800)
`genroute` was allocating an array for edge computation upfront. But what it was
not accounting for was that some of the functions it later calls _change_ the
`pn` value it used to determine how many array elements it should allocate.
Specifically, `Pshortestpath` can add new points to the polygon, thereby causing
the walk of the (now too short) array to write out of bounds.

Gitlab: fixes #42
Reported-by: mattjj
CHANGELOG.md
lib/neatogen/multispline.c
tests/test_regression.py

index c6e5136172cf302a34b333ba17bba5ce31d7d731..558b026880ccfda2ac0760f36ebd9a5c9acc10d1 100644 (file)
@@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
   7.0.2. Complete #2277, #2303
 - Several compilation errors when building Smyrna on macOS have been fixed. This
   was a regression in Graphviz 7.0.1.
+- A crash when using neato layout with large inferred per-node edge counts was
+  fixed. #42
 
 ## [7.0.1] – 2022-11-09
 
index cd3f9dbabb027bdb9912043db5bef6575d42ef3d..061b756cb501721e7ebd825f67e8d14f9a15d527 100644 (file)
@@ -790,7 +790,7 @@ static int genroute(tripoly_t * trip, int s, int t, edge_t * e, int doPolyline)
     Ppolyline_t pl, spl;
     int i, j;
     Ppolyline_t mmpl;
-    Pedge_t *medges = N_GNEW(trip->poly.pn, Pedge_t);
+    Pedge_t *medges = NULL;
     int pn;
     int mult = ED_count(e);
     node_t* head = aghead(e);
@@ -816,6 +816,7 @@ static int genroute(tripoly_t * trip, int s, int t, edge_t * e, int doPolyline)
 
     if ((mult == 1) || Concentrate) {
        poly = trip->poly;
+       medges = N_GNEW(poly.pn, Pedge_t);
        for (j = 0; j < poly.pn; j++) {
            medges[j].a = poly.ps[j];
            medges[j].b = poly.ps[(j + 1) % poly.pn];
@@ -867,6 +868,7 @@ static int genroute(tripoly_t * trip, int s, int t, edge_t * e, int doPolyline)
            make_polyline (mmpl, &spl);
        }
        else {
+           medges = N_GNEW(poly.pn, Pedge_t);
            for (j = 0; j < poly.pn; j++) {
                medges[j].a = poly.ps[j];
                medges[j].b = poly.ps[(j + 1) % poly.pn];
index 0e727f3a7b933fb296f651259375679815970076..405f426b3a6b449f930eb455205510f863600683 100644 (file)
@@ -75,7 +75,6 @@ def test_14():
   dot("svg", input)
 
 @pytest.mark.skipif(which("neato") is None, reason="neato not available")
-@pytest.mark.xfail()
 def test_42():
   """
   check for a former crash in neatogen