Skip to content

Commit 6371dc7

Browse files
committed
merge revision(s) 22694,22947:
* util.c (ruby_dtoa): allocates one more byte to get rid of buffer overrun. a patch from Charlie Savage at [ruby-core:22604]. * 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]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@23630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 81d792d commit 6371dc7

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
Wed Jun 3 21:09:56 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
2+
3+
* util.c (rv_strdup): macro to duplicate nul-terminated string.
4+
[ruby-core:22852]
5+
6+
* util.c (ruby_dtoa): allocates one more byte to get rid of buffer
7+
overrun. a patch from Charlie Savage at [ruby-core:22604].
8+
9+
Wed Jun 3 21:09:56 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
10+
11+
* util.c (ruby_dtoa): allocates one more byte to get rid of buffer
12+
overrun. a patch from Charlie Savage at [ruby-core:22604].
13+
114
Wed Jun 3 21:05:44 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
215

316
* ext/bigdecimal/bigdecimal.c (gfDebug): uncommented out.

util.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3116,13 +3116,15 @@ nrv_alloc(const char *s, char **rve, int n)
31163116
{
31173117
char *rv, *t;
31183118

3119-
t = rv = rv_alloc(n);
3119+
t = rv = rv_alloc(n+1);
31203120
while ((*t = *s++) != 0) t++;
31213121
if (rve)
31223122
*rve = t;
31233123
return rv;
31243124
}
31253125

3126+
#define rv_strdup(s, rve) nrv_alloc(s, rve, strlen(s)+1)
3127+
31263128
/* freedtoa(s) must be used to free values s returned by dtoa
31273129
* when MULTIPLE_THREADS is #defined. It should be used in all cases,
31283130
* but for consistency with earlier versions of dtoa, it is optional
@@ -3256,17 +3258,17 @@ dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
32563258
*decpt = 9999;
32573259
#ifdef IEEE_Arith
32583260
if (!word1(d) && !(word0(d) & 0xfffff))
3259-
return nrv_alloc("Infinity", rve, 8);
3261+
return rv_strdup("Infinity", rve);
32603262
#endif
3261-
return nrv_alloc("NaN", rve, 3);
3263+
return rv_strdup("NaN", rve);
32623264
}
32633265
#endif
32643266
#ifdef IBM
32653267
dval(d) += 0; /* normalize */
32663268
#endif
32673269
if (!dval(d)) {
32683270
*decpt = 1;
3269-
return nrv_alloc("0", rve, 1);
3271+
return rv_strdup("0", rve);
32703272
}
32713273

32723274
#ifdef SET_INEXACT
@@ -3409,7 +3411,7 @@ dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
34093411
if (i <= 0)
34103412
i = 1;
34113413
}
3412-
s = s0 = rv_alloc(i);
3414+
s = s0 = rv_alloc(i+1);
34133415

34143416
#ifdef Honor_FLT_ROUNDS
34153417
if (mode > 1 && rounding != 1)

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define RUBY_RELEASE_DATE "2009-06-03"
33
#define RUBY_VERSION_CODE 187
44
#define RUBY_RELEASE_CODE 20090603
5-
#define RUBY_PATCHLEVEL 169
5+
#define RUBY_PATCHLEVEL 170
66

77
#define RUBY_VERSION_MAJOR 1
88
#define RUBY_VERSION_MINOR 8

0 commit comments

Comments
 (0)