From: Eric Wong <normalperson@yhbt.net>
To: sleepy.penguin@librelist.org
Subject: [sleepy.penguin] [PATCH] value2timespec: use StringValueCStr for correctness
Date: Thu, 21 Nov 2013 18:48:42 +0000 [thread overview]
Message-ID: <20131121184842.GB9059@dcvr.yhbt.net> (raw)
In-Reply-To: <20131121184842.GB9059@dcvr.yhbt.net>
rb_inspect is unlikely to put a \0 byte in the middle of a string,
but use StringValueCStr anyways just in case to catch potential bugs.
---
ext/sleepy_penguin/value2timespec.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ext/sleepy_penguin/value2timespec.h b/ext/sleepy_penguin/value2timespec.h
index 8f6830b..b8f6167 100644
--- a/ext/sleepy_penguin/value2timespec.h
+++ b/ext/sleepy_penguin/value2timespec.h
@@ -42,8 +42,8 @@ static struct timespec *value2timespec(struct timespec *ts, VALUE num)
}}
{
VALUE tmp = rb_inspect(num);
- rb_raise(rb_eTypeError, "can't convert %s into timespec",
- StringValuePtr(tmp));
+ const char *str = StringValueCStr(tmp);
+ rb_raise(rb_eTypeError, "can't convert %s into timespec", str);
}
rb_bug("rb_raise() failed, timespec failed");
return NULL;
--
1.8.5.rc2.1.g2f4e96a
parent reply other threads:[~2013-11-21 18:48 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20131121184842.GB9059@dcvr.yhbt.net>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/sleepy_penguin/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131121184842.GB9059@dcvr.yhbt.net \
--to=normalperson@yhbt.net \
--cc=sleepy.penguin@librelist.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/sleepy_penguin.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).