After this change, a ASan+UBSan build of Graphviz can process the #1999 example
without crashing. Graphs with >46341 (⌈√INT_MAX⌉) nodes no longer cause an
integer overflow.
Gitlab: fixes #1999
Reported-by: Lockywolf
- The Autotools build system no longer errors when attempting libANN discovery
during cross-compilation. This was a regression in Graphviz 7.0.6. #2335
+- Graphs with more than 46341 (⌈√INT_MAX⌉) nodes no longer crash `twopi`. #1999
## [7.0.6] – 2023-01-06
* Contributors: Details at https://graphviz.org
*************************************************************************/
-
+#include <assert.h>
#include <pathplan/vis.h>
#include <stdbool.h>
#include <stdlib.h>
array2 arr;
COORD *p;
+ assert(V >= 0);
arr = malloc((V + extra) * sizeof(COORD *));
- p = calloc(V * V, sizeof(COORD));
+ p = calloc((size_t)V * (size_t)V, sizeof(COORD));
for (i = 0; i < V; i++) {
arr[i] = p;
p += V;