Hi,

	problem is that buf is sometimes not freed.


--- ../ruby-09-06/sprintf.c	Fri Sep  6 20:55:37 2002
+++ sprintf.c	Sat Sep  7 19:37:00 2002
@@ -140,6 +140,7 @@ rb_f_sprintf(argc, argv)
       retry:
 	switch (*p) {
 	  default:
+	    free(buf);
 	    if (ISPRINT(*p))
 		rb_raise(rb_eArgError, "malformed format string - %%%c", *p);
 	    else
@@ -178,6 +179,7 @@ rb_f_sprintf(argc, argv)
 		n = 10 * n + (*p - '0');
 	    }
 	    if (p >= end) {
+		free(buf);
 		rb_raise(rb_eArgError, "malformed format string - %%[0-9]");
 	    }
 	    if (*p == '$') {
@@ -191,6 +193,7 @@ rb_f_sprintf(argc, argv)
 
 	  case '*':
 	    if (flags & FWIDTH) {
+		free(buf);
 		rb_raise(rb_eArgError, "width given twice");
 	    }
 
@@ -205,6 +208,7 @@ rb_f_sprintf(argc, argv)
 
 	  case '.':
 	    if (flags & FPREC) {
+		free(buf);
 		rb_raise(rb_eArgError, "precision given twice");
 	    }
 	    flags |= FPREC;
@@ -224,6 +228,7 @@ rb_f_sprintf(argc, argv)
 		prec = 10 * prec + (*p - '0');
 	    }
 	    if (p >= end) {
+		free(buf);
 		rb_raise(rb_eArgError, "malformed format string - %%.[0-9]");
 	    }
 	    goto retry;
@@ -233,6 +238,7 @@ rb_f_sprintf(argc, argv)
 	  case '\0':
 	  case '%':
 	    if (flags != FNONE) {
+		free(buf);
 		rb_raise(rb_eArgError, "illegal format character - %%");
 	    }
 	    PUSH("%", 1);

=======================================================================
PS: Please note that it leaks when exception is raised!

Example:

@@ -335,12 +341,12 @@ rb_f_sprintf(argc, argv)
 	      bin_retry:
 		switch (TYPE(val)) {
 		  case T_FLOAT:
-		    val = rb_dbl2big(RFLOAT(val)->value);
+		    val = rb_dbl2big(RFLOAT(val)->value); /* FIXME: MemLeak when exc. is raised */
 		    if (FIXNUM_P(val)) goto bin_retry;
 		    bignum = 1;
 		    break;
 		  case T_STRING:
-		    val = rb_str_to_inum(val, 0, Qtrue);
+		    val = rb_str_to_inum(val, 0, Qtrue); /* FIXME: ditto */
 		    goto bin_retry;
 		  case T_BIGNUM:
 		    bignum = 1;
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Michal Rokos                         Czech Technical University, Prague
E-mail:m.rokos / sh.cvut.cz      ICQ:36118339      Jabber:majkl / jabber.cz
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-