* string.c (rb_str_buf_cat_escaped_char): get rid of buffer
overflow on platforms int is bigger than 32bit, and warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0363b91bf6
commit
88eb029a2c
@ -1,3 +1,8 @@
|
|||||||
|
Sun Jun 6 22:37:11 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (rb_str_buf_cat_escaped_char): get rid of buffer
|
||||||
|
overflow on platforms int is bigger than 32bit, and warnings.
|
||||||
|
|
||||||
Sun Jun 6 19:55:21 2010 Tanaka Akira <akr@fsij.org>
|
Sun Jun 6 19:55:21 2010 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* array.c (rb_ary_product): clear uninitialized elements in temporary
|
* array.c (rb_ary_product): clear uninitialized elements in temporary
|
||||||
@ -40,7 +45,7 @@ Sat Jun 5 20:30:49 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
|||||||
* re.c (rb_reg_expr_str): use rb_str_buf_cat_escaped_char
|
* re.c (rb_reg_expr_str): use rb_str_buf_cat_escaped_char
|
||||||
when resenc is given: for Regexp#inspect or error message.
|
when resenc is given: for Regexp#inspect or error message.
|
||||||
|
|
||||||
* re.c (rb_reg_desc): add 'n' for ENCODING_NONE.
|
* re.c (rb_reg_desc): add 'n' for ENCODING_NONE.
|
||||||
|
|
||||||
Sat Jun 5 01:20:14 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
Sat Jun 5 01:20:14 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
9
string.c
9
string.c
@ -4081,9 +4081,14 @@ str_cat_char(VALUE str, unsigned int c, rb_encoding *enc)
|
|||||||
#define CHAR_ESC_LEN 13 /* sizeof(\x{ hex of 32bit unsigned int } \0) */
|
#define CHAR_ESC_LEN 13 /* sizeof(\x{ hex of 32bit unsigned int } \0) */
|
||||||
|
|
||||||
int
|
int
|
||||||
rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p) {
|
rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p)
|
||||||
|
{
|
||||||
char buf[CHAR_ESC_LEN + 1];
|
char buf[CHAR_ESC_LEN + 1];
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
|
#if SIZEOF_INT > 4
|
||||||
|
c &= 0xffffffff;
|
||||||
|
#endif
|
||||||
if (unicode_p) {
|
if (unicode_p) {
|
||||||
if (c < 0x7F && ISPRINT(c)) {
|
if (c < 0x7F && ISPRINT(c)) {
|
||||||
snprintf(buf, CHAR_ESC_LEN, "%c", c);
|
snprintf(buf, CHAR_ESC_LEN, "%c", c);
|
||||||
@ -4103,7 +4108,7 @@ rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p) {
|
|||||||
snprintf(buf, CHAR_ESC_LEN, "\\x{%X}", c);
|
snprintf(buf, CHAR_ESC_LEN, "\\x{%X}", c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
l = strlen(buf);
|
l = (int)strlen(buf); /* CHAR_ESC_LEN cannot exceed INT_MAX */
|
||||||
rb_str_buf_cat(result, buf, l);
|
rb_str_buf_cat(result, buf, l);
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user