diff -cwr gimp-1.2.4-pre1/plug-ins/script-fu/script-fu-server.c gimp-1.2.4-pre1-ft/plug-ins/script-fu/script-fu-server.c
*** gimp-1.2.4-pre1/plug-ins/script-fu/script-fu-server.c	Fri Nov  9 11:15:16 2001
--- gimp-1.2.4-pre1-ft/plug-ins/script-fu/script-fu-server.c	Sat Jun 29 00:06:05 2002
***************
*** 517,522 ****
--- 649,655 ----
    va_end (args);
  
    fputs (buf, server_log_file);
+   g_free (buf);
    if (server_log_file != stdout)
      fflush (server_log_file);
  }
diff -cwr gimp-1.2.4-pre1/plug-ins/script-fu/script-fu.c gimp-1.2.4-pre1-ft/plug-ins/script-fu/script-fu.c
*** gimp-1.2.4-pre1/plug-ins/script-fu/script-fu.c	Mon Apr  9 01:52:38 2001
--- gimp-1.2.4-pre1-ft/plug-ins/script-fu/script-fu.c	Sat Jun 29 02:56:37 2002
***************
*** 15,20 ****
--- 15,26 ----
   * 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,551 ****
--- 552,563 ----
  				      &params, &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)
***************
*** 553,564 ****
        g_snprintf (error_str, sizeof (error_str), 
  		  "Invalid arguments supplied to %s--(# args: %ld, expecting: %d)",
  		  proc_name, (nlength (a) - 1), nparams);
        return my_err (error_str, NIL);
      }
  
    /*  Marshall the supplied arguments  */
    if (nparams)
!     args = g_new (GimpParam, nparams);
    else
      args = NULL;
  
--- 565,578 ----
        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_new0 (GimpParam, nparams);
    else
      args = NULL;
  
***************
*** 676,683 ****
  
  		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);
  		array = args[i].data.d_stringarray = 
  		  g_new (char *, num_strings);
  
--- 690,702 ----
  
  		list = car (a);
  		num_strings = args[i - 1].data.d_int32;
! 		if (nlength (list) != num_strings) {
!     	          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,711 ****
--- 725,734 ----
  	  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,781 ****
--- 794,810 ----
  	  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,816 ****
--- 836,851 ----
  	  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);
  	}
  
***************
*** 819,826 ****
  
    if (success)
      values = gimp_run_procedure2 (proc_name, &nvalues, nparams, args);
!   else
      return my_err ("Invalid types specified for arguments", NIL);
  
    /*  Check the return status  */
    if (! values)
--- 854,865 ----
  
    if (success)
      values = gimp_run_procedure2 (proc_name, &nvalues, nparams, args);
!   else {
!         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)
***************
*** 828,833 ****
--- 867,876 ----
        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,847 ****
--- 879,897 ----
      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,899 ****
--- 944,953 ----
  	      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,950 ****
--- 999,1005 ----
  		  }
  
  		return_val = cons (nreverse (string_array), return_val);
+ 		g_free (array);
  	      }
  	      break;
  
***************
*** 957,962 ****
--- 1012,1021 ----
  	      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,1000 ****
--- 1050,1067 ----
  	      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,1036 ****
--- 1094,1111 ----
  	      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,1058 ****
    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);
  
--- 1123,1128 ----
