sleepy_penguin RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* [sleepy.penguin] [PATCH] value2timespec: use StringValueCStr for correctness
@ 2013-11-21 18:48 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2013-11-21 18:48 UTC (permalink / raw)
  To: sleepy.penguin

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



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-11-21 18:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-21 18:48 [sleepy.penguin] [PATCH] value2timespec: use StringValueCStr for correctness Eric Wong

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).