From 6831f5f82bcb55340452cbc8a419beae9a47af73 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 16 Mar 2009 15:47:17 +0000 Subject: Do not leak the mime description --- (limited to 'browser-plugin') diff --git a/browser-plugin/glue.cpp b/browser-plugin/glue.cpp index 148f566..986cae8 100644 --- a/browser-plugin/glue.cpp +++ b/browser-plugin/glue.cpp @@ -34,26 +34,32 @@ NPNetscapeFuncs NPNFuncs; +static char *mimeDescription = NULL; + char * NP_GetMIMEDescription (void) { ev_init (); - GString *desc = g_string_new (NULL); - GList *all_types = ev_backends_manager_get_all_types_info (); + if (mimeDescription == NULL) { + GString *desc = g_string_new (NULL); + GList *all_types = ev_backends_manager_get_all_types_info (); - for (GList *l = all_types; l; l = g_list_next (l)){ - EvTypeInfo *info = (EvTypeInfo *)l->data; - const char *mime; - int i = 0; + for (GList *l = all_types; l; l = g_list_next (l)){ + EvTypeInfo *info = (EvTypeInfo *)l->data; + const char *mime; + int i = 0; - while ((mime = info->mime_types[i++])) { - g_string_append_printf (desc, "%s:%s:;", - mime, info->desc); + while ((mime = info->mime_types[i++])) { + g_string_append_printf ( + desc, "%s:%s:;", mime, info->desc); + } } + + mimeDescription = g_string_free (desc, FALSE); } - return g_string_free (desc, FALSE); + return mimeDescription; } NPError @@ -114,6 +120,9 @@ NP_Initialize (NPNetscapeFuncs *aNPNFuncs, NPPluginFuncs *aNPPFuncs) NPError NP_Shutdown (void) { + g_free(mimeDescription); + mimeDescription = NULL; + return NPERR_NO_ERROR; } -- cgit v0.9.1