From 8c1a84e23c78bc02f5d9b76f4d3d8d35343df2ea Mon Sep 17 00:00:00 2001 From: "Emden R. Gansner" Date: Tue, 25 Mar 2014 09:50:01 -0400 Subject: [PATCH] Simplify gvusershape_find(); fix bug 2425. With the use of cgraph, the strings used in attributes are attached to the root graph, so file name pointers being stored in the image cache are no longer valid when the graph is deleted. The image cache needs to use the global string cache. As this could lead to many unsed image cache items, we might consider limiting the cache size, or starting afresh with each new graph. --- lib/gvc/gvusershape.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/gvc/gvusershape.c b/lib/gvc/gvusershape.c index c8476a5b7..7869a26a2 100644 --- a/lib/gvc/gvusershape.c +++ b/lib/gvc/gvusershape.c @@ -572,7 +572,7 @@ static Dtdisc_t ImageDictDisc = { usershape_t *gvusershape_find(char *name) { - usershape_t probe, *us; + usershape_t *us; assert(name); assert(name[0]); @@ -580,8 +580,7 @@ usershape_t *gvusershape_find(char *name) if (!ImageDict) return NULL; - probe.name = name; - us = dtsearch(ImageDict, &probe); + us = dtmatch(ImageDict, name); return us; } @@ -643,7 +642,7 @@ static usershape_t *gvusershape_open (char *name) if (! (us = zmalloc(sizeof(usershape_t)))) return NULL; - us->name = name; + us->name = agstrdup (0, name); if (!gvusershape_file_access(us)) return NULL; -- 2.40.0