From 63a5fcd96f53761630a37fff7657db5d03619a7d Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 7 Sep 2022 17:27:49 -0700 Subject: [PATCH] remove calls to 'rsvg_term' MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The `rsvg_term` function has been a no-op for some time:¹ rsvg_term has been deprecated since version 2.36 and should not be used in newly-written code. There is no need to de-initialize librsvg. This function does nothing. Graphviz was calling it when linked against librsvg 2.36 (2.36.0 was released 2012-03-26). I do not know why this code was conditional as `rsvg_term` has been a no-op since 2.35.0.² Moreover, calling it prior to it becoming a no-op was wrong too. The commit that removed its functionality notes: rsvg_term() was dangerous to call The problem is that it previously called libxml2’s `xmlCleanupParser` whose documentation states:³ This function name is somewhat misleading. It does not clean up parser state, it cleans up memory allocated by the library itself. It is a cleanup function for the XML library. It tries to reclaim all related global memory allocated for the library processing. It doesn't deallocate any document related memory. One should call xmlCleanupParser() only when the process has finished using the library and all XML/HTML documents built with it. See also xmlInitParser() which has the opposite function of preparing the library for operations. WARNING: if your application is multithreaded or has plugin support calling this may crash the application if another thread or a plugin is still using libxml2. It's sometimes very hard to guess if libxml2 is in use in the application, some libraries or plugins may use it without notice. In case of doubt abstain from calling this function or do it just before calling exit() to avoid leak reports from valgrind ! This seems to have come to light ~2010.⁴ But presumably there is still a long tail of software in the wild still, like Graphviz, erroneously calling `rsvg_term`. ¹ https://www.manpagez.com/html/rsvg-2.0/rsvg-2.0-2.52.1/RsvgHandle.php#rsvg-term ² Commit 7f27418cfcdea9cdd6b2bf81ea0b0f6cc5a18b30 of librsvg. ³ https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlCleanupParser ⁴ https://lists.fedoraproject.org/pipermail/devel/2010-January/129117.html https://bugzilla.redhat.com/show_bug.cgi?id=542277 https://bugzilla.gnome.org/show_bug.cgi?id=592100 --- plugin/rsvg/gvloadimage_rsvg.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/plugin/rsvg/gvloadimage_rsvg.c b/plugin/rsvg/gvloadimage_rsvg.c index 87e173412..3fc83a788 100644 --- a/plugin/rsvg/gvloadimage_rsvg.c +++ b/plugin/rsvg/gvloadimage_rsvg.c @@ -78,9 +78,6 @@ static RsvgHandle* gvloadimage_rsvg_load(GVJ_t * job, usershape_t *us) if (rsvgh == NULL) { fprintf(stderr, "rsvg_handle_new_from_file returned an error: %s\n", err->message); -#ifndef HAVE_SVG_2_36 - rsvg_term(); -#endif return NULL; } @@ -95,9 +92,6 @@ static RsvgHandle* gvloadimage_rsvg_load(GVJ_t * job, usershape_t *us) g_object_unref(rsvgh); #else rsvg_handle_free(rsvgh); -#endif -#ifndef HAVE_SVG_2_36 - rsvg_term(); #endif return NULL; } @@ -110,9 +104,6 @@ static RsvgHandle* gvloadimage_rsvg_load(GVJ_t * job, usershape_t *us) g_object_unref(rsvgh); #else rsvg_handle_free(rsvgh); -#endif -#ifndef HAVE_SVG_2_36 - rsvg_term(); #endif return NULL; } @@ -124,9 +115,6 @@ static RsvgHandle* gvloadimage_rsvg_load(GVJ_t * job, usershape_t *us) g_object_unref(rsvgh); #else rsvg_handle_free(rsvgh); -#endif -#ifndef HAVE_SVG_2_36 - rsvg_term(); #endif return NULL; } -- 2.40.0