Merged Irssi SVN (upcoming irssi 0.8.11).
[silc.git] / apps / irssi / src / perl / perl-core.c
index 2d300289cd60b8ebe237c2ce42ea0aba123c2647..2b660eefa813405aa73cb1538f8214180ccc70e4 100644 (file)
@@ -160,7 +160,12 @@ void perl_scripts_deinit(void)
 
        /* Unload all perl libraries loaded with dynaloader */
        perl_eval_pv("foreach my $lib (@DynaLoader::dl_modules) { if ($lib =~ /^Irssi\\b/) { $lib .= '::deinit();'; eval $lib; } }", TRUE);
-       perl_eval_pv("eval { foreach my $lib (@DynaLoader::dl_librefs) { DynaLoader::dl_unload_file($lib); } }", TRUE);
+
+       /* We could unload all libraries .. but this crashes with some
+          libraries, probably because we don't call some deinit function..
+          Anyway, this would free some memory with /SCRIPT RESET, but it
+          leaks memory anyway. */
+       /*perl_eval_pv("eval { foreach my $lib (@DynaLoader::dl_librefs) { DynaLoader::dl_unload_file($lib); } }", TRUE);*/
 
        /* perl interpreter */
        perl_destruct(my_perl);
@@ -368,11 +373,13 @@ char *perl_script_get_path(const char *name)
                /* check from SCRIPTDIR */
                g_free(path);
                path = g_strdup_printf(SCRIPTDIR"/%s", file);
-               if (stat(path, &statbuf) != 0)
-                        path = NULL;
+               if (stat(path, &statbuf) != 0) {
+                       g_free(path);
+                       path = NULL;
+               }
        }
        g_free(file);
-        return path;
+       return path;
 }
 
 /* If core should handle printing script errors */
@@ -463,8 +470,8 @@ void perl_core_init(void)
 
 void perl_core_deinit(void)
 {
-       perl_signals_deinit();
         perl_scripts_deinit();
+       perl_signals_deinit();
 
        signal_remove("script error", (SIGNAL_FUNC) sig_script_error);
 }