summaryrefslogtreecommitdiff
path: root/ext/socket/socket.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-06 04:14:57 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-06 04:14:57 +0000
commit8c6c73745ec6ace79e2fbb3655439acfb2d82f62 (patch)
tree820c2d5484d1281e5e034f63f1bc7d6963cca671 /ext/socket/socket.c
parent24ee6971cc7405dd504aff16d7964687e510d00d (diff)
* ext/socket/socket.c (rsock_sys_fail_path): Use rb_str_inspect only
for String to avoid SEGV. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r--ext/socket/socket.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index be7bd62..3ee725d 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -29,16 +29,21 @@ void
rsock_sys_fail_path(const char *mesg, VALUE path)
{
VALUE message;
- if (memchr(RSTRING_PTR(path), '\0', RSTRING_LEN(path))) {
- path = rb_str_inspect(path);
- message = rb_sprintf("%s for %s", mesg,
- StringValueCStr(path));
+ if (RB_TYPE_P(path, T_STRING)) {
+ if (memchr(RSTRING_PTR(path), '\0', RSTRING_LEN(path))) {
+ path = rb_str_inspect(path);
+ message = rb_sprintf("%s for %s", mesg,
+ StringValueCStr(path));
+ }
+ else {
+ message = rb_sprintf("%s for \"%s\"", mesg,
+ StringValueCStr(path));
+ }
+ rb_sys_fail_str(message);
}
else {
- message = rb_sprintf("%s for \"%s\"", mesg,
- StringValueCStr(path));
+ rb_sys_fail(mesg);
}
- rb_sys_fail_str(message);
}
void