[PATCH] Call xmlCleanupParser only once - when we are done with libxml

Miika Turkia miika.turkia at gmail.com
Tue Sep 18 08:40:31 PDT 2012


On Tue, Sep 18, 2012 at 6:33 PM, Lubomir I. Ivanov <neolit123 at gmail.com> wrote:
> From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
>
> Calling xmlCleanupParser in parse-xml.c:parse_xml_buffer()
> caused massive memory corruption mostly affecting gtk's FileChooser
> dialogs and the application menu.
>
> Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>

Excellent! This fixes the crash issue for me.

Acked-by: Miika Turkia <miika.turkia at gmail.com>

> ---
>  dive.h      | 1 +
>  main.c      | 3 +++
>  parse-xml.c | 6 +++++-
>  3 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/dive.h b/dive.h
> index 5637edf..d756eba 100644
> --- a/dive.h
> +++ b/dive.h
> @@ -385,6 +385,7 @@ static inline struct dive *get_dive(unsigned int nr)
>
>  extern void parse_xml_init(void);
>  extern void parse_xml_buffer(const char *url, const char *buf, int size, GError **error);
> +extern void parse_xml_exit(void);
>  extern void set_filename(const char *filename, gboolean force);
>
>  extern void parse_file(const char *filename, GError **error);
> diff --git a/main.c b/main.c
> index 2bdccd2..d3bd443 100644
> --- a/main.c
> +++ b/main.c
> @@ -253,5 +253,8 @@ int main(int argc, char **argv)
>                 show_dive_info(NULL);
>         run_ui();
>         exit_ui();
> +
> +       parse_xml_exit();
> +
>         return 0;
>  }
> diff --git a/parse-xml.c b/parse-xml.c
> index f47ac5a..2a10792 100644
> --- a/parse-xml.c
> +++ b/parse-xml.c
> @@ -1497,7 +1497,6 @@ void parse_xml_buffer(const char *url, const char *buffer, int size, GError **er
>         traverse(xmlDocGetRootElement(doc));
>         dive_end();
>         xmlFreeDoc(doc);
> -       xmlCleanupParser();
>  }
>
>  void parse_xml_init(void)
> @@ -1505,6 +1504,11 @@ void parse_xml_init(void)
>         LIBXML_TEST_VERSION
>  }
>
> +void parse_xml_exit(void)
> +{
> +       xmlCleanupParser();
> +}
> +
>  #ifdef XSLT
>
>  /* Maybe we'll want a environment variable that can override this.. */
> --
> 1.7.11.msysgit.0
>
> _______________________________________________
> subsurface mailing list
> subsurface at hohndel.org
> http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface


More information about the subsurface mailing list