ruby-changes:11332
From: nobu <ko1@a...>
Date: Sat, 14 Mar 2009 14:22:06 +0900 (JST)
Subject: [ruby-changes:11332] Ruby:r22947 (ruby_1_8): * util.c (rv_strdup): macro to duplicate nul-terminated string.
nobu 2009-03-14 14:21:58 +0900 (Sat, 14 Mar 2009) New Revision: 22947 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22947 Log: * util.c (rv_strdup): macro to duplicate nul-terminated string. [ruby-core:22852] * util.c (ruby_dtoa): allocates one more byte to get rid of buffer overrun. a patch from Charlie Savage at [ruby-core:22604]. Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/util.c Index: ruby_1_8/util.c =================================================================== --- ruby_1_8/util.c (revision 22946) +++ ruby_1_8/util.c (revision 22947) @@ -3116,13 +3116,15 @@ { char *rv, *t; - t = rv = rv_alloc(n); + t = rv = rv_alloc(n+1); while ((*t = *s++) != 0) t++; if (rve) *rve = t; return rv; } +#define rv_strdup(s, rve) nrv_alloc(s, rve, strlen(s)+1) + /* freedtoa(s) must be used to free values s returned by dtoa * when MULTIPLE_THREADS is #defined. It should be used in all cases, * but for consistency with earlier versions of dtoa, it is optional @@ -3256,9 +3258,9 @@ *decpt = 9999; #ifdef IEEE_Arith if (!word1(d) && !(word0(d) & 0xfffff)) - return nrv_alloc("Infinity", rve, 8); + return rv_strdup("Infinity", rve); #endif - return nrv_alloc("NaN", rve, 3); + return rv_strdup("NaN", rve); } #endif #ifdef IBM @@ -3266,7 +3268,7 @@ #endif if (!dval(d)) { *decpt = 1; - return nrv_alloc("0", rve, 1); + return rv_strdup("0", rve); } #ifdef SET_INEXACT Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 22946) +++ ruby_1_8/ChangeLog (revision 22947) @@ -1,3 +1,11 @@ +Sat Mar 14 14:21:56 2009 Nobuyoshi Nakada <nobu@r...> + + * util.c (rv_strdup): macro to duplicate nul-terminated string. + [ruby-core:22852] + + * util.c (ruby_dtoa): allocates one more byte to get rid of buffer + overrun. a patch from Charlie Savage at [ruby-core:22604]. + Fri Mar 13 19:44:21 2009 Yukihiro Matsumoto <matz@r...> * eval.c (rb_call0): should pass rest argument information even -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/