edgepaint: fix 'free' of invalid pointer
When building using CMake and -DCMAKE_BUILD_TYPE=Release
on MinGW, the
compiler says:
In function 'node_distinct_coloring',
inlined from 'edge_distinct_coloring' at C:/GitLab-Runner/builds/smattr/graphviz/lib/edgepaint/edge_distinct_coloring.c:239:12,
inlined from 'clarify' at C:/GitLab-Runner/builds/smattr/graphviz/cmd/edgepaint/edgepaintmain.c:251:7,
inlined from 'main' at C:/GitLab-Runner/builds/smattr/graphviz/cmd/edgepaint/edgepaintmain.c:281:7:
C:/GitLab-Runner/builds/smattr/graphviz/lib/edgepaint/node_distinct_coloring.c:231:5: error: 'free' called on pointer 'p_1108' with nonzero offset 240000 [-Werror=free-nonheap-object]
231 | free(color_points);
| ^
In function 'gv_calloc',
inlined from 'color_blend_rgb2lab' at C:/GitLab-Runner/builds/smattr/graphviz/lib/edgepaint/lab.c:258:20,
inlined from 'node_distinct_coloring' at C:/GitLab-Runner/builds/smattr/graphviz/lib/edgepaint/node_distinct_coloring.c:227:28,
inlined from 'edge_distinct_coloring' at C:/GitLab-Runner/builds/smattr/graphviz/lib/edgepaint/edge_distinct_coloring.c:239:12,
inlined from 'clarify' at C:/GitLab-Runner/builds/smattr/graphviz/cmd/edgepaint/edgepaintmain.c:251:7,
inlined from 'main' at C:/GitLab-Runner/builds/smattr/graphviz/cmd/edgepaint/edgepaintmain.c:281:7:
C:/GitLab-Runner/builds/smattr/graphviz/lib/cgraph/alloc.h:35:13: note: returned from 'calloc'
35 | void *p = calloc(nmemb, size);
| ^
LTO enables the compiler to see the allocated pointer is actually conditionally
incremented within color_blend_rgb2lab
before being returned. So the eventual
call to free
can pass in the incremented pointer, instead of the original.
Gitlab: fixes #2513 (closed)