diff -ruN gimp-1.2.4-pre2/plug-ins/script-fu/script-fu-server.c gimp-1.2.4-pre2-ft/plug-ins/script-fu/script-fu-server.c --- gimp-1.2.4-pre2/plug-ins/script-fu/script-fu-server.c Mon Jun 17 08:31:04 2002 +++ gimp-1.2.4-pre2-ft/plug-ins/script-fu/script-fu-server.c Mon Apr 21 03:51:35 2003 @@ -529,6 +529,7 @@ va_end (args); fputs (buf, server_log_file); + g_free (buf); if (server_log_file != stdout) fflush (server_log_file); } diff -ruN gimp-1.2.4-pre2/plug-ins/script-fu/script-fu.c gimp-1.2.4-pre2-ft/plug-ins/script-fu/script-fu.c --- gimp-1.2.4-pre2/plug-ins/script-fu/script-fu.c Sun Apr 8 11:52:38 2001 +++ gimp-1.2.4-pre2-ft/plug-ins/script-fu/script-fu.c Mon Apr 21 04:02:14 2003 @@ -15,6 +15,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* + * Sat Jun 29 00:30:57 EST 2002 - Cameron, http://www.flamingtext.com/ + * Better memory cleanup as per Sven! + * Thu Jun 27 13:00:22 EST 2002 - Cameron, http://www.flamingtext.com/ + * Cleaned up some (leaking) memory problems. + */ #include "config.h" @@ -546,19 +552,27 @@ ¶ms, &return_vals)) return my_err ("Invalid procedure name specified.", NIL); - + /** free the unused stuff straight away */ + g_free (proc_blurb); + g_free (proc_help); + g_free (proc_author); + g_free (proc_copyright); + g_free (proc_date); + /* Check the supplied number of arguments */ if ((nlength (a) - 1) != nparams) { g_snprintf (error_str, sizeof (error_str), "Invalid arguments supplied to %s--(# args: %ld, expecting: %d)", proc_name, (nlength (a) - 1), nparams); + g_free (params); + g_free (return_vals); return my_err (error_str, NIL); } /* Marshall the supplied arguments */ if (nparams) - args = g_new (GimpParam, nparams); + args = g_new0 (GimpParam, nparams); else args = NULL; @@ -677,7 +691,13 @@ list = car (a); num_strings = args[i - 1].data.d_int32; if (nlength (list) != num_strings) - return my_err ("String array argument has incorrectly specified length", NIL); + { + g_free (args); + //gimp_destroy_params (args, nparams); + g_free (params); + g_free (return_vals); + return my_err ("String array argument has incorrectly specified length", NIL); + } array = args[i].data.d_stringarray = g_new (char *, num_strings); @@ -706,6 +726,10 @@ break; case GIMP_PDB_REGION: + g_free (args); + //gimp_destroy_params (args, nparams); + g_free (params); + g_free (return_vals); return my_err ("Regions are currently unsupported as arguments", car (a)); break; @@ -771,11 +795,17 @@ break; case GIMP_PDB_BOUNDARY: + g_free (args); + g_free (params); + g_free (return_vals); return my_err ("Boundaries are currently unsupported as arguments", car (a)); break; case GIMP_PDB_PATH: + g_free (args); + g_free (params); + g_free (return_vals); return my_err ("Paths are currently unsupported as arguments", car (a)); break; @@ -807,10 +837,16 @@ break; case GIMP_PDB_STATUS: + g_free (args); + g_free (params); + g_free (return_vals); return my_err ("Status is for return types, not arguments", car (a)); break; default: + g_free (args); + g_free (params); + g_free (return_vals); return my_err ("Unknown argument type", NIL); } @@ -820,14 +856,22 @@ if (success) values = gimp_run_procedure2 (proc_name, &nvalues, nparams, args); else - return my_err ("Invalid types specified for arguments", NIL); + { + g_free (args); + g_free (params); + g_free (return_vals); + return my_err ("Invalid types specified for arguments", NIL); + } /* Check the return status */ if (! values) { strcpy (error_str, "Procedural database execution did not return a status:\n "); lprin1s (a_saved, error_str + strlen(error_str)); - + gimp_destroy_params (values, nvalues); + g_free (args); + g_free (params); + g_free (return_vals); return my_err (error_str, NIL); } @@ -836,12 +880,19 @@ case GIMP_PDB_EXECUTION_ERROR: strcpy (error_str, "Procedural database execution failed:\n "); lprin1s (a_saved, error_str + strlen(error_str)); + gimp_destroy_params (values, nvalues); + g_free (args); + g_free (params); + g_free (return_vals); return my_err (error_str, NIL); break; case GIMP_PDB_CALLING_ERROR: strcpy (error_str, "Procedural database execution failed on invalid input arguments:\n "); lprin1s (a_saved, error_str + strlen(error_str)); + g_free (args); + g_free (params); + g_free (return_vals); return my_err (error_str, NIL); break; @@ -894,6 +945,10 @@ break; case GIMP_PDB_INT16ARRAY: + gimp_destroy_params (values, nvalues); + g_free (args); + g_free (params); + g_free (return_vals); return my_err ("Arrays are currently unsupported as return values", NIL); break; @@ -945,6 +1000,7 @@ } return_val = cons (nreverse (string_array), return_val); + g_free (array); } break; @@ -957,6 +1013,10 @@ break; case GIMP_PDB_REGION: + gimp_destroy_params (values, nvalues); + g_free (args); + g_free (params); + g_free (return_vals); return my_err ("Regions are currently unsupported as return values", NIL); break; @@ -991,10 +1051,18 @@ break; case GIMP_PDB_BOUNDARY: + gimp_destroy_params (values, nvalues); + g_free (args); + g_free (params); + g_free (return_vals); return my_err ("Boundaries are currently unsupported as return values", NIL); break; case GIMP_PDB_PATH: + gimp_destroy_params (values, nvalues); + g_free (args); + g_free (params); + g_free (return_vals); return my_err ("Paths are currently unsupported as return values", NIL); break; @@ -1027,10 +1095,18 @@ break; case GIMP_PDB_STATUS: + gimp_destroy_params (values, nvalues); + g_free (args); + g_free (params); + g_free (return_vals); return my_err ("Procedural database execution returned multiple status values", NIL); break; default: + gimp_destroy_params (values, nvalues); + g_free (args); + g_free (params); + g_free (return_vals); return my_err ("Unknown return type", NIL); } } @@ -1048,11 +1124,6 @@ g_free (args); /* free the query information */ - g_free (proc_blurb); - g_free (proc_help); - g_free (proc_author); - g_free (proc_copyright); - g_free (proc_date); g_free (params); g_free (return_vals);